daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top