Automatically run npm install when running npm start (#35283)
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,3 +32,4 @@ user-code/
|
|||||||
# Logs from scripts
|
# Logs from scripts
|
||||||
script/logs/
|
script/logs/
|
||||||
external-link-checker-db.json
|
external-link-checker-db.json
|
||||||
|
.installed.package-lock.json
|
||||||
|
|||||||
5
.npmrc
5
.npmrc
@@ -1,2 +1,7 @@
|
|||||||
# skip installing optional dependencies to avoid issues with troublesome `fsevents` module
|
# skip installing optional dependencies to avoid issues with troublesome `fsevents` module
|
||||||
omit=optional
|
omit=optional
|
||||||
|
|
||||||
|
# For 15-25% faster npm install
|
||||||
|
# https://www.peterbe.com/plog/benchmarking-npm-install-with-or-without-audit
|
||||||
|
# Also we have Dependabot alerts configured in the GitHub repo.
|
||||||
|
audit=false
|
||||||
|
|||||||
@@ -198,6 +198,7 @@
|
|||||||
"prevent-pushes-to-main": "node script/prevent-pushes-to-main.js",
|
"prevent-pushes-to-main": "node script/prevent-pushes-to-main.js",
|
||||||
"rest-dev": "src/rest/scripts/update-files.js",
|
"rest-dev": "src/rest/scripts/update-files.js",
|
||||||
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
|
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
|
||||||
|
"prestart": "script/cmp-files.js package-lock.json .installed.package-lock.json || npm install && cp package-lock.json .installed.package-lock.json",
|
||||||
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon server.js",
|
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon server.js",
|
||||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
||||||
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
|
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
|
||||||
|
|||||||
31
script/cmp-files.js
Executable file
31
script/cmp-files.js
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// [start-readme]
|
||||||
|
//
|
||||||
|
// Given N files. Exit 0 if they all exist and are identical in content.
|
||||||
|
//
|
||||||
|
// [end-readme]
|
||||||
|
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
import { program } from 'commander'
|
||||||
|
|
||||||
|
program.description('Compare N files').arguments('[files...]', '').parse(process.argv)
|
||||||
|
|
||||||
|
main(program.args)
|
||||||
|
|
||||||
|
function main(files) {
|
||||||
|
if (files.length < 2) throw new Error('Must be at least 2 files')
|
||||||
|
try {
|
||||||
|
const contents = files.map((file) => fs.readFileSync(file, 'utf-8'))
|
||||||
|
if (new Set(contents).size > 1) {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
process.exit(1)
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user