3 - nodejs_version: "0.10"
4 - nodejs_version: "0.12"
5 - nodejs_version: "1.8"
6 - nodejs_version: "2.5"
7 - nodejs_version: "3.3"
8 - nodejs_version: "4.9"
9 - nodejs_version: "5.12"
10 - nodejs_version: "6.17"
11 - nodejs_version: "7.10"
12 - nodejs_version: "8.17"
13 - nodejs_version: "9.11"
14 - nodejs_version: "10.24"
15 - nodejs_version: "11.15"
16 - nodejs_version: "12.22"
17 - nodejs_version: "13.14"
18 - nodejs_version: "14.19"
19 - nodejs_version: "15.14"
20 - nodejs_version: "16.14"
26 try { Install-Product node $env:nodejs_version -ErrorAction Stop }
27 catch { Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) }
30 npm config set loglevel error
31 npm config set shrinkwrap false
32 # Remove all non-test dependencies
34 # Remove example dependencies
35 npm rm --silent --save-dev connect-redis
36 # Remove lint dependencies
37 cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
38 sls "^eslint(-|$)" | `
39 %{ npm rm --silent --save-dev $_ }
40 # Setup Node.js version-specific dependencies
43 # - use 3.x for Node.js < 4
44 # - use 5.x for Node.js < 6
45 # - use 6.x for Node.js < 8
46 # - use 7.x for Node.js < 10
47 # - use 8.x for Node.js < 12
48 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
49 npm install --silent --save-dev mocha@3.5.3
50 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
51 npm install --silent --save-dev mocha@5.2.0
52 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
53 npm install --silent --save-dev mocha@6.2.2
54 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
55 npm install --silent --save-dev mocha@7.2.0
56 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 12) {
57 npm install --silent --save-dev mocha@8.4.0
60 # nyc for test coverage
61 # - use 10.3.2 for Node.js < 4
62 # - use 11.9.0 for Node.js < 6
63 # - use 14.1.1 for Node.js < 8
64 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
65 npm install --silent --save-dev nyc@10.3.2
66 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
67 npm install --silent --save-dev nyc@11.9.0
68 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
69 npm install --silent --save-dev nyc@14.1.1
72 # supertest for http calls
73 # - use 2.0.0 for Node.js < 4
74 # - use 3.4.2 for Node.js < 6
75 # - use 6.1.6 for Node.js < 8
76 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
77 npm install --silent --save-dev supertest@2.0.0
78 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
79 npm install --silent --save-dev supertest@3.4.2
80 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
81 npm install --silent --save-dev supertest@6.1.6
83 # Update Node.js modules
85 # Prune & rebuild node_modules
86 if (Test-Path -Path node_modules) {
90 # Install Node.js modules