mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-19 12:57:16 +00:00
Convert clean-shrinkwrap.js to typescript
Change-type: patch
This commit is contained in:
parent
9ce97be6a4
commit
7d72e0c046
7
Makefile
7
Makefile
@ -150,10 +150,7 @@ sass:
|
||||
node-sass lib/gui/app/scss/main.scss > lib/gui/css/main.css
|
||||
|
||||
lint-ts:
|
||||
resin-lint --typescript lib tests webpack.config.ts
|
||||
|
||||
lint-js:
|
||||
eslint --ignore-pattern scripts/resin/**/*.js scripts
|
||||
resin-lint --typescript lib tests scripts/clean-shrinkwrap.ts webpack.config.ts
|
||||
|
||||
lint-sass:
|
||||
sass-lint lib/gui/scss
|
||||
@ -168,7 +165,7 @@ lint-spell:
|
||||
--skip *.svg *.gz,*.bz2,*.xz,*.zip,*.img,*.dmg,*.iso,*.rpi-sdcard,*.wic,.DS_Store,*.dtb,*.dtbo,*.dat,*.elf,*.bin,*.foo,xz-without-extension \
|
||||
lib tests docs Makefile *.md LICENSE
|
||||
|
||||
lint: lint-ts lint-js lint-sass lint-cpp lint-spell
|
||||
lint: lint-ts lint-sass lint-cpp lint-spell
|
||||
|
||||
MOCHA_OPTIONS=--recursive --reporter spec --require ts-node/register
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make lint test sanity-checks",
|
||||
"prettier": "prettier --config ./node_modules/resin-lint/config/.prettierrc --write \"lib/**/*.ts\" \"lib/**/*.tsx\" \"tests/**/*.ts\" \"webpack.config.ts\"",
|
||||
"prettier": "prettier --config ./node_modules/resin-lint/config/.prettierrc --write \"lib/**/*.ts\" \"lib/**/*.tsx\" \"tests/**/*.ts\" \"webpack.config.ts\" \"scripts/clean-shrinkwrap.ts\"",
|
||||
"start": "./node_modules/.bin/electron .",
|
||||
"postshrinkwrap": "node ./scripts/clean-shrinkwrap.js",
|
||||
"postshrinkwrap": "ts-node ./scripts/clean-shrinkwrap.ts",
|
||||
"configure": "node-gyp configure",
|
||||
"build": "node-gyp build",
|
||||
"install": "node-gyp rebuild",
|
||||
|
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* 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)}`)
|
||||
}
|
||||
})
|
48
scripts/clean-shrinkwrap.ts
Normal file
48
scripts/clean-shrinkwrap.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import { writeFile } from 'fs';
|
||||
import * as omit from 'omit-deep-lodash';
|
||||
import * as path from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
import * as shrinkwrap from '../npm-shrinkwrap.json';
|
||||
import * as packageInfo from '../package.json';
|
||||
|
||||
const writeFileAsync = promisify(writeFile);
|
||||
|
||||
const JSON_INDENT = 2;
|
||||
const SHRINKWRAP_FILENAME = path.join(__dirname, '..', 'npm-shrinkwrap.json');
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const cleaned = omit(shrinkwrap, packageInfo.platformSpecificDependencies);
|
||||
await writeFileAsync(
|
||||
SHRINKWRAP_FILENAME,
|
||||
JSON.stringify(cleaned, null, JSON_INDENT),
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(`[ERROR] Couldn't write shrinkwrap file: ${error.stack}`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
console.log(
|
||||
`[OK] Wrote shrinkwrap file to ${path.relative(
|
||||
__dirname,
|
||||
SHRINKWRAP_FILENAME,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
1
typings/omit-deep-lodash/index.d.ts
vendored
Normal file
1
typings/omit-deep-lodash/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'omit-deep-lodash';
|
Loading…
x
Reference in New Issue
Block a user