From ec25c7dff893dca748d26e052cf2407d9475ac5e Mon Sep 17 00:00:00 2001 From: Ben Kucera <14625260+Bkucera@users.noreply.github.com> Date: Mon, 22 Jul 2019 12:30:52 -0400 Subject: [PATCH] chore(windows): make install portable to windows (#4779) * chore(install) - make preinstall hook windows portable - make link-packages script use junction symlinks for windows * use npx * run preinstll in appveyor * remove win32 check, pin dep (and update .npmrc) --- .npmrc | 1 + appveyor.yml | 1 + package.json | 3 ++- scripts/link-packages.js | 9 +-------- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.npmrc b/.npmrc index 90ce1783cb..6984758ba6 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,4 @@ loglevel=warn progress=false package-lock=false +save-exact=true diff --git a/appveyor.yml b/appveyor.yml index 72dc41fab3..a0ab300d40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -64,6 +64,7 @@ install: # clean cache to prevent install permission issues - npm cache clean --force # install root modules only, and retry automatically if install fails + - npm run preinstall - npm install --ignore-scripts || npm install --ignore-scripts || npm install --ignore-scripts - .\node_modules\.bin\print-arch # because we skipped scripts, we need to do diff --git a/package.json b/package.json index 014e6dc443..e08b22dc4d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dev-debug": "node ./scripts/debug.js dev", "docker": "./scripts/run-docker-local.sh", "effective:circle:config": "circleci config process circle.yml | sed /^#/d", - "preinstall": "rm -rf node_modules/@packages || true", + "preinstall": "npx shx rm -rf node_modules/@packages", "postinstall": "echo 'root postinstall' && npm run link && npm run all install && npm run build", "install-filtered": "npm run all install -- --package $(node ./scripts/check-deps.js --list)", "jscodeshift": "jscodeshift -t ./node_modules/js-codemod/transforms/arrow-function-arguments.js", @@ -151,6 +151,7 @@ "proxyquire": "2.1.0", "ramda": "0.24.1", "shelljs": "0.8.3", + "shx": "0.3.2", "sinon": "7.3.2", "snap-shot-it": "7.8.0", "stop-only": "3.0.1", diff --git a/scripts/link-packages.js b/scripts/link-packages.js index f6c0dfc6e2..2b448a0afe 100644 --- a/scripts/link-packages.js +++ b/scripts/link-packages.js @@ -32,18 +32,11 @@ function makeLinks () { const basename = path.basename(dirname) const destinationLink = path.join(pathToPackages, basename) - // const registerPath = path.join(destinationFolder, 'register.js') - // const fullMain = path.resolve(dirname, json.main) - - // debug('full name', fullMain) - // const relativePathToMain = path.relative(destinationFolder, fullMain) - - // debug('relative path to main', relativePathToMain) const relativePathToDest = path.relative(path.dirname(destinationLink), dirname) console.log(destinationLink, '->', relativePathToDest) - return fs.symlink(relativePathToDest, destinationLink) + return fs.symlink(relativePathToDest, destinationLink, 'junction') }) }) }