-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add postinstall script for apps under cfgov-refresh #3831
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
This script handles installing node dependencies for a project that lives | ||
under cfgov-refresh, but has its own package.json. These projects appear | ||
under the ./cfgov/unprocessed/apps/ path. | ||
*/ | ||
|
||
const fs = require( 'fs' ); | ||
const exec = require( 'child_process' ).exec; | ||
|
||
const paths = require( '../../../config/environment' ).paths; | ||
|
||
// Aggregate application namespaces that appear in unprocessed/apps. | ||
// eslint-disable-next-line no-sync | ||
let apps = fs.readdirSync( `${ paths.unprocessed }/apps/` ); | ||
|
||
// Filter out .DS_STORE directory. | ||
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. Trivial: This could be more broadly stated "Filter out hidden directories" 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. Fixed in #3834 |
||
apps = apps.filter( dir => dir.charAt( 0 ) !== '.' ); | ||
|
||
// Run each application's JS through webpack and store the gulp streams. | ||
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. Is this actually happening? Looks like all it's doing is running 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. Fixed in #3834 |
||
apps.forEach( app => { | ||
/* Check if node_modules directory exists in a particular app's folder. | ||
If it doesn't log the command to add it and don't process the scripts. */ | ||
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. Trivial: Could use a comma after "doesn't" for clarity. 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. Fixed in #3834 |
||
const appsPath = `${ paths.unprocessed }/apps/${ app }`; | ||
// eslint-disable-next-line no-sync | ||
if ( fs.existsSync( `${ appsPath }/package.json` ) ) { | ||
exec( `npm --prefix ${ appsPath } install ${ appsPath }`, | ||
( error, stdout, stderr ) => { | ||
// eslint-disable-next-line no-console | ||
console.log( 'App\'s npm output: ' + stdout ); | ||
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. Is it possible to use 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. Great idea! 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. Fixed in #3834 |
||
// eslint-disable-next-line no-console | ||
console.log( 'App\'s npm errors: ' + stderr ); | ||
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. Are there always errors/warnings? Should this get a condition check like 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. Fixed in #3834 |
||
if ( error !== null ) { | ||
// eslint-disable-next-line no-console | ||
console.log( 'App\'s exec error: ' + error ); | ||
} | ||
} | ||
); | ||
} | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this, PR, but this should probably be changed to run our actual test suites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we have #3576 and #2303 that overlap with that.