Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const FILE_TYPES = {
- template: ['html', 'jade', 'slim'],
- style: ['css', 'scss', 'less', 'styl'],
- script: ['js', 'coffee'],
- asset: ['png', 'jpeg', 'jpg', 'svg', 'ico']
- }
- const prepareRawFile = filePath => {
- const extension = path.extname(filePath)
- const name = path.basename(filePath, extension)
- const ext = extension.split('.').join('')
- let type
- _.keys(FILE_TYPES).map(fileType => {
- if (FILE_TYPES[fileType].includes(ext)) type = fileType
- })
- return {
- name,
- type,
- ext,
- path: filePath
- }
- }
- const scanSourceDirectory = async (sourcePath) => {
- const rawFiles = await glob(`${sourcePath}/**/*.*`)
- .then(files => files.map(prepareRawFile))
- // console.log(rawFiles)
- return rawFiles
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement