adding support to multiple sources#6
Conversation
kennyki
left a comment
There was a problem hiding this comment.
Hey thanks for the PR. However I have few things to clarify, please see the comments
| }) | ||
|
|
||
| const vueFiles = glob.sync(`${srcFolder}/**/*.vue`) | ||
| const getFileArrays = (fileExtension = 'vue') => srcFolder.map(src => glob.sync(`${src}/**/*.${fileExtension}`)) |
There was a problem hiding this comment.
- Would
srcFolder.mapfail if only onesrcis provided? - Perhaps
getFilesis a better name :-)
There was a problem hiding this comment.
oh i forgot it.
thanks for feedback. I'm renaming the function. I'll update PR soon
|
|
||
| const vueFiles = glob.sync(`${srcFolder}/**/*.vue`) | ||
| const getFileArrays = (fileExtension = 'vue') => srcFolder.map(src => glob.sync(`${src}/**/*.${fileExtension}`)) | ||
| const flattenFiles = (fileExtension = 'vue') => [].concat.apply([], getFileArrays()) |
There was a problem hiding this comment.
Is this function necessary?
Because it doesn't make use of fileExtension and is creating an additional array from the results of getFileArrays
Perhaps we can just call:
const vueFiles = getFiles()
const jsFiles = getFiles('js').concat(vueFiles)
There was a problem hiding this comment.
glob.sync generates an array... so i'll have a multiple array... that's will be generate an erro.
but i fix that using a reduce function to help that
const syncFiles = (src, fileExtension = 'vue') => glob.sync(`${src}/**/*.${fileExtension}`)
const getFiles = (fileExtension = 'vue') => srcFolder.reduce((files, src) => [...files, ...syncFiles(src, fileExtension)], [])
const vueFiles = Array.isArray(srcFolder) ? getFiles() : syncFiles(srcFolder)
// note: vue files contain js code too
const jsFiles = Array.isArray(srcFolder) ? getFiles('js') : syncFiles(srcFolder, 'js')
const files = [...jsFiles, ...vueFiles]
what do you think about that?
|
I was going to comment on this if somebody could review this/resolve conflicts because I encountered the same problem but after checking the source code I found that this package already supports multiple sources because it uses |
hello,
in the structure of my project using nuxt I need to pass multiple srcs.
the extract.js file is not validating srcs array.
So I made this code to help