Skip to content

Commit

Permalink
Run npm install as needed after checkouts and merges (#46230)
Browse files Browse the repository at this point in the history
  • Loading branch information
heiskr authored Nov 27, 2023
1 parent dc767f6 commit 1154921
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"move-content": "node src/content-render/scripts/move-content.js",
"openapi-docs": "node src/rest/docs.js",
"playwright-test": "playwright test --config src/fixtures/playwright.config.ts --project=\"Google Chrome\"",
"postinstall": "cp package-lock.json .installed.package-lock.json && echo \"Updated .installed.package-lock.json\" # see husky/post-checkout and husky/post-merge",
"prepare": "husky install src/workflows/husky",
"prettier": "prettier -w \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
"prettier-check": "prettier -c \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"",
"prevent-pushes-to-main": "node src/workflows/prevent-pushes-to-main.js",
"rest-dev": "node 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-",
"prestart": "node src/workflows/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 src/frame/server.js",
"start-all-languages": "cross-env NODE_ENV=development nodemon src/frame/server.js",
"start-for-playwright": "cross-env ROOT=src/fixtures/fixtures TRANSLATIONS_FIXTURE_ROOT=src/fixtures/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node src/frame/server.js",
Expand Down
14 changes: 14 additions & 0 deletions src/workflows/husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

# Same process in husky/post-merge
echo "Check if any packages need to be installed"
if [[ $(node src/workflows/cmp-files.js package-lock.json .installed.package-lock.json) -eq 0 ]]
then
echo "Packages are ready"
else
echo "Installing packages"
npm install
echo "Installed packages"
fi
14 changes: 14 additions & 0 deletions src/workflows/husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

# Same process in husky/post-checkout
echo "Check if any packages need to be installed"
if [[ $(node src/workflows/cmp-files.js package-lock.json .installed.package-lock.json) -eq 0 ]]
then
echo "Packages are ready"
else
echo "Installing packages"
npm install
echo "Installed packages"
fi

0 comments on commit 1154921

Please sign in to comment.