Skip to content

Commit 0ce1aea

Browse files
committed
Make npm-postinstall.sh more robust
1 parent b3ae4d6 commit 0ce1aea

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ci/build/npm-postinstall.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ set -eu
44
main() {
55
cd lib/vscode
66

7+
case "${npm_config_user_agent-}" in npm*)
8+
# We are running under npm.
9+
if [ "${npm_config_unsafe_perm-}" != "true" ]; then
10+
echo "Please pass --unsafe-perm to npm to install code-server"
11+
echo "Otherwise the postinstall script does not have permissions to run"
12+
echo "See https://docs.npmjs.com/misc/config#unsafe-perm"
13+
echo "See https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm"
14+
exit 1
15+
fi
16+
;;
17+
esac
18+
719
# We have to rename node_modules.bundled to node_modules.
820
# The bundled modules were renamed originally to avoid being ignored by yarn.
9-
local node_modules
1021
node_modules="$(find . -depth -name "node_modules.bundled")"
11-
local nm
1222
for nm in $node_modules; do
1323
rm -Rf "${nm%.bundled}"
1424
mv "$nm" "${nm%.bundled}"
1525
done
1626

27+
# $npm_config_global makes npm rebuild return without rebuilding.
28+
unset npm_config_global
1729
# Rebuilds native modules.
1830
npm rebuild
1931
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-server",
33
"license": "MIT",
4-
"version": "3.3.0-rc.21",
4+
"version": "3.3.0-rc.24",
55
"description": "Run VS Code on a remote server.",
66
"homepage": "https://github.com/cdr/code-server",
77
"bugs": {

0 commit comments

Comments
 (0)