mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Add clean-shrinkwrap script to postshrinkwrap step
Change-type: patch Changelog-entry: Add clean-shrinkwrap script to postshrinkwrap step Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzoa@balena.io>
This commit is contained in:
parent
b65526d8ee
commit
aa52735006
@ -318,8 +318,6 @@ rules:
|
||||
- always
|
||||
prefer-const:
|
||||
- error
|
||||
prefer-reflect:
|
||||
- error
|
||||
prefer-spread:
|
||||
- error
|
||||
prefer-numeric-literals:
|
||||
|
11
npm-shrinkwrap.json
generated
11
npm-shrinkwrap.json
generated
@ -8844,6 +8844,15 @@
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"omit-deep-lodash": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/omit-deep-lodash/-/omit-deep-lodash-1.1.4.tgz",
|
||||
"integrity": "sha512-5ge7dBDVDYEU8YiqYlKxjsVesB3wqXejgluGx+9Xd8+PJH7VEEK9D4Pqpq7VE0ZtQh9HBz0LMNRk1BA3+bsd4Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lodash": "~4.17.11"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
@ -13952,4 +13961,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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. <hello@etcher.io>",
|
||||
"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",
|
||||
|
37
scripts/clean-shrinkwrap.js
Normal file
37
scripts/clean-shrinkwrap.js
Normal file
@ -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)}`)
|
||||
}
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user