Files
etcher/scripts/shrinkwrap.js
Juan Cruz Viotti ea1df5cc11 chore: make use of ESLint (#540)
JSCS has merged with ESLint. This is the perfect excuse to move to
ESLint and unify both JSHint and JSCS hints under ESLint.

This PR also deprecates `gulp lint` in favour of `npm run lint`.

See: https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.zbuwvxa5y
Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
2016-06-30 20:09:44 +05:30

39 lines
1.3 KiB
JavaScript

/**
* This script is in charge of generating the `shrinkwrap` file.
*
* `npm shrinkwrap` has a bug where it will add optional dependencies
* to `npm-shrinkwrap.json`, therefore causing errors if these optional
* dependendencies are platform dependent and you then try to build
* the project in another platform.
*
* As a workaround, we keep a list of platform dependent dependencies in
* the `shrinkwrapIgnore` property of `package.json`, and manually remove
* them from `npm-shrinkwrap.json` if they exists.
*
* See: https://github.com/npm/npm/issues/2679
*/
'use strict';
const _ = require('lodash');
const path = require('path');
const jsonfile = require('jsonfile');
const childProcess = require('child_process');
const shrinkwrapIgnore = require('../package.json').shrinkwrapIgnore;
const SHRINKWRAP_PATH = path.join(__dirname, '..', 'npm-shrinkwrap.json');
try {
console.log(childProcess.execSync('npm shrinkwrap', {
cwd: path.dirname(SHRINKWRAP_PATH)
}));
} catch (error) {
console.error(error.stderr.toString());
process.exit(1);
}
const shrinkwrapContents = jsonfile.readFileSync(SHRINKWRAP_PATH);
shrinkwrapContents.dependencies = _.omit(shrinkwrapContents.dependencies, shrinkwrapIgnore);
jsonfile.writeFileSync(SHRINKWRAP_PATH, shrinkwrapContents, {
spaces: 2
});