-
Notifications
You must be signed in to change notification settings - Fork 110
helper.js: GetFolders -> GetModules, add package.json existence check #697
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -145,17 +145,21 @@ const GetDepTree = ( name ) => { | |||||
|
||||||
|
||||||
/** | ||||||
* Get all folders within a given path | ||||||
* Get all modules within a given path. | ||||||
* Module is folder with package.json | ||||||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||||||
* | ||||||
* @param {string} thisPath - The path that contains the desired folders | ||||||
* @param {boolean} verbose - Verbose flag either undefined or true | ||||||
* | ||||||
* @return {array} - An array of names of each folder | ||||||
*/ | ||||||
const GetFolders = ( thisPath, verbose ) => { | ||||||
const GetModules = ( thisPath, verbose ) => { | ||||||
try { | ||||||
let folders = Fs.readdirSync( thisPath ).filter( | ||||||
thisFile => Fs.statSync(`${ thisPath }/${ thisFile }`).isDirectory() | ||||||
thisFile => { | ||||||
let path = `${ thisPath }/${ thisFile }`; | ||||||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||||||
return Fs.statSync(path).isDirectory() && Fs.existsSync(`${path}/package.json`) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are going to refactor this function I think making it asynchronous would be really beneficial. Currently a lot of the code in I like the readability changes but if we're updating this, we should make it really nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there are a lot of stuff which can be run asynchronous. OK, i can "promisify" this function and change calling code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We might need to put a |
||||||
} | ||||||
).filter( | ||||||
thisFile => thisFile !== 'core' | ||||||
); | ||||||
|
@@ -620,7 +624,7 @@ HELPER.generate = (() => { | |||||
*/ | ||||||
init: () => { | ||||||
const packagesPath = Path.normalize(`${ __dirname }/../packages/`); | ||||||
const allModules = GetFolders( packagesPath ); | ||||||
const allModules = GetModules( packagesPath ); | ||||||
|
||||||
HELPER.generate.json( allModules ); | ||||||
HELPER.generate.index( allModules ); | ||||||
|
@@ -889,7 +893,7 @@ HELPER.test = (() => { | |||||
return { | ||||||
init: () => { | ||||||
const packagesPath = Path.normalize(`${ __dirname }/../packages/`); | ||||||
const allModules = GetFolders( packagesPath ); | ||||||
const allModules = GetModules( packagesPath ); | ||||||
|
||||||
HELPER.test.dependencies( allModules ); | ||||||
HELPER.test.packagejson( allModules ); | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.