Skip to content

Commit 4931c32

Browse files
committed
chore(ci): fix npm cache path for windows; remove the whole cache folder when installing
1 parent 2b7110c commit 4931c32

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

.evergreen/functions.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ functions:
152152
153153
# Make all the dirs
154154
mkdir -p $ARTIFACTS_PATH
155-
mkdir -p $NPM_CACHE_DIR
156-
mkdir -p $NPM_TMP_DIR
157155
158156
- command: shell.exec
159157
type: setup

.evergreen/npm_ci.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
set -e
44

5-
npm cache clean -f
5+
# Remove the cache and any potential install leftovers before installing again.
6+
# We are running this script with a retry to deal with network issues, in some
7+
# rare cases npm leaves stuff behind messing up a new attempt
8+
if [ -n "$NPM_CACHE_DIR" ]; then
9+
rm -rf "$NPM_CACHE_DIR"
10+
fi
611
rm -rf node_modules
712
find configs -name 'node_modules' -type d -prune -exec rm -rf '{}' +
813
find packages -name 'node_modules' -type d -prune -exec rm -rf '{}' +
914
find scripts -name 'node_modules' -type d -prune -exec rm -rf '{}' +
10-
npm ci --unsafe-perm
15+
npm ci --unsafe-perm

.evergreen/print-compass-env.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env node
22
'use strict';
3+
const path = require('path');
34

45
/*
56
This script writes a bash script that can be eval()'d in evergreen to modify the
@@ -79,18 +80,16 @@ function printCompassEnv() {
7980
PATH = maybePrependPaths(PATH, pathsToPrepend);
8081
printVar('PATH', PATH);
8182

82-
const npmCacheDir = `${newPWD}/.deps/.npm`;
83-
const npmTmpDir = `${newPWD}/.deps/tmp`;
83+
// not using `newPWD` here to avoid issues on windows where the value supposed
84+
// to be a non-cygwin path
85+
const npmCacheDir = path.resolve(__dirname, '..', '.deps', '.npm-cache');
8486

8587
printVar('ARTIFACTS_PATH', `${newPWD}/.deps`);
8688
printVar('NPM_CACHE_DIR', npmCacheDir);
87-
printVar('NPM_TMP_DIR', npmTmpDir);
8889

8990
// all npm var names need to be lowercase
9091
// see: https://docs.npmjs.com/cli/v7/using-npm/config#environment-variables
9192
printVar('npm_config_cache', npmCacheDir);
92-
// npm tmp is deprecated, but let's keep it around just in case
93-
printVar('npm_config_tmp', npmTmpDir);
9493
// Also set in our .npmrc but that does not get picked up in the preinstall script.
9594
printVar('npm_config_registry', 'https://registry.npmjs.org/');
9695

0 commit comments

Comments
 (0)