Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. const FILE_TYPES = {
  2. template: ['html', 'jade', 'slim'],
  3. style: ['css', 'scss', 'less', 'styl'],
  4. script: ['js', 'coffee'],
  5. asset: ['png', 'jpeg', 'jpg', 'svg', 'ico']
  6. }
  7.  
  8. const prepareRawFile = filePath => {
  9. const extension = path.extname(filePath)
  10. const name = path.basename(filePath, extension)
  11. const ext = extension.split('.').join('')
  12. let type
  13.  
  14. _.keys(FILE_TYPES).map(fileType => {
  15. if (FILE_TYPES[fileType].includes(ext)) type = fileType
  16. })
  17.  
  18. return {
  19. name,
  20. type,
  21. ext,
  22. path: filePath
  23. }
  24. }
  25.  
  26. const scanSourceDirectory = async (sourcePath) => {
  27. const rawFiles = await glob(`${sourcePath}/**/*.*`)
  28. .then(files => files.map(prepareRawFile))
  29. // console.log(rawFiles)
  30. return rawFiles
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement