-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 #2768 from balena-io/clean-shrinkwrap
Add clean-shrinkwrap script to postshrinkwrap step
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"scripts": { | ||
"test": "make lint test sanity-checks", | ||
"start": "./node_modules/.bin/electron .", | ||
"postshrinkwrap": "node ./scripts/clean-shrinkwrap.js", | ||
"configure": "node-gyp configure", | ||
"build": "node-gyp build", | ||
"install": "node-gyp rebuild", | ||
|
@@ -32,6 +33,10 @@ | |
}, | ||
"author": "Balena Inc. <[email protected]>", | ||
"license": "Apache-2.0", | ||
"platformSpecificDependencies": [ | ||
"fsevents", | ||
"winusb-driver-generator" | ||
], | ||
"dependencies": { | ||
"@fortawesome/fontawesome-free-webfonts": "^1.0.9", | ||
"angular": "1.7.6", | ||
|
@@ -104,6 +109,7 @@ | |
"nock": "^9.2.3", | ||
"node-gyp": "^3.8.0", | ||
"node-sass": "^4.7.2", | ||
"omit-deep-lodash": "1.1.4", | ||
"pkg": "^4.3.0", | ||
"sass-lint": "^1.12.1", | ||
"simple-progress-webpack-plugin": "^1.1.2", | ||
|
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,37 @@ | ||
/** | ||
* This script is in charge of cleaning 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 `platformSpecificDependencies` property of `package.json`, | ||
* and manually remove them from `npm-shrinkwrap.json` if they exist. | ||
* | ||
* See: https://github.com/npm/npm/issues/2679 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const omit = require('omit-deep-lodash') | ||
|
||
const JSON_INDENT = 2 | ||
const SHRINKWRAP_FILENAME = path.join(__dirname, '..', 'npm-shrinkwrap.json') | ||
|
||
const packageInfo = require('../package.json') | ||
const shrinkwrap = require('../npm-shrinkwrap.json') | ||
|
||
const cleaned = omit(shrinkwrap, packageInfo.platformSpecificDependencies) | ||
|
||
fs.writeFile(SHRINKWRAP_FILENAME, JSON.stringify(cleaned, null, JSON_INDENT), (error) => { | ||
if (error) { | ||
console.log(`[ERROR] Couldn't write shrinkwrap file: ${error.stack}`) | ||
process.exitCode = 1 | ||
} else { | ||
console.log(`[OK] Wrote shrinkwrap file to ${path.relative(__dirname, SHRINKWRAP_FILENAME)}`) | ||
} | ||
}) |
Submodule resin
updated
from c80a0d to 1a1e90