-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3831 from cfpb/app_npm_install
Add postinstall script for apps under cfgov-refresh
- Loading branch information
Showing
4 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
cfgov/unprocessed/apps/cfgov/unprocessed/apps/owning-a-home/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
apps = apps.filter( dir => dir.charAt( 0 ) !== '.' ); | ||
|
||
// Run each application's JS through webpack and store the gulp streams. | ||
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. */ | ||
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 ); | ||
// eslint-disable-next-line no-console | ||
console.log( 'App\'s npm errors: ' + stderr ); | ||
if ( error !== null ) { | ||
// eslint-disable-next-line no-console | ||
console.log( 'App\'s exec error: ' + error ); | ||
} | ||
} | ||
); | ||
} | ||
} ); |