build(npm): add tools/npm/reshrinkwrap script and update docs

This commit is contained in:
Igor Minar
2016-01-02 21:47:09 -08:00
committed by Igor Minar
parent 625474c4e2
commit a0d25db4a5
4 changed files with 33 additions and 29 deletions

View File

@ -27,12 +27,12 @@ function cleanModule(moduleRecord, name) {
}
console.log('Reading npm-shrinkwrap.json');
//console.log('Reading npm-shrinkwrap.json');
var shrinkwrap = require('../../npm-shrinkwrap.json');
console.log('Cleaning shrinkwrap object');
//console.log('Cleaning shrinkwrap object');
cleanModule(shrinkwrap, shrinkwrap.name);
var cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json');
console.log('Writing cleaned to', cleanShrinkwrapPath);
console.log('writing npm-shrinkwrap.clean.json');
fs.writeFileSync(cleanShrinkwrapPath, JSON.stringify(sorted(shrinkwrap), null, 2) + "\n");

View File

@ -11,6 +11,7 @@ var PROJECT_ROOT = path.join(__dirname, '../../');
process.chdir(PROJECT_ROOT);
if (fs.existsSync(NPM_SHRINKWRAP_FILE)) {
console.log('copying shrinkwrap fingerprint to', NPM_SHRINKWRAP_CACHED_FILE);
fse.copySync(NPM_SHRINKWRAP_FILE, NPM_SHRINKWRAP_CACHED_FILE);
} else {
console.warn(`${NPM_SHRINKWRAP_FILE} not found. Copy operation will be skipped.`);

15
tools/npm/reshrinkwrap Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env node
'use strict';
let childProcess = require('child_process');
childProcess.spawn('npm', ['shrinkwrap', '--dev'], {stdio: 'inherit'}).on('exit', (exitCode) => {
if (exitCode !== 0) return;
childProcess.fork('./tools/npm/clean-shrinkwrap.js').on('exit', (exitCode) => {
if (exitCode !== 0) return;
childProcess.fork('./tools/npm/copy-npm-shrinkwrap');
});
});