-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add various compatibility layers (#5)
- Loading branch information
Showing
70 changed files
with
3,392 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
jobs: | ||
linux-lts: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: lts/* | ||
- name: Check | ||
run: | | ||
which node | ||
node -v | ||
which npm | ||
npm -v | ||
linux-stable: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: node | ||
- name: Check | ||
run: | | ||
which node | ||
node -v | ||
which npm | ||
npm -v | ||
linux-exact: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: "10.0.0" | ||
- name: Check | ||
run: | | ||
which node | ||
node -v | ||
which npm | ||
npm -v | ||
if [ $(node -v) != "v10.0.0" ]; then | ||
exit 1; | ||
fi | ||
linux-nvmrc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
- name: Check | ||
run: | | ||
which node | ||
node -v | ||
which npm | ||
npm -v | ||
if [ $(node -v) != "v12.9.0" ]; then | ||
exit 1; | ||
fi | ||
linux-canary: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: latest | ||
node-mirror: https://nodejs.org/download/v8-canary/ | ||
- name: Check | ||
run: | | ||
which node | ||
node -v | ||
which npm | ||
npm -v | ||
windows-lts: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: lts/* | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
windows-stable: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: node | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
windows-exact: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: "10.0.0" | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
# windows-nvmrc: | ||
# runs-on: windows-latest | ||
# steps: | ||
# - uses: actions/checkout@master | ||
# - uses: ./ | ||
# - name: Check | ||
# run: | | ||
# node -v | ||
# npm -v | ||
# windows-canary: | ||
# runs-on: windows-latest | ||
# steps: | ||
# - uses: actions/checkout@master | ||
# - uses: ./ | ||
# with: | ||
# node-version: latest | ||
# node-mirror: https://nodejs.org/download/v8-canary/ | ||
# - name: Check | ||
# run: | | ||
# node -v | ||
# npm -v | ||
macos-lts: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: lts/* | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
macos-stable: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: node | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
macos-exact: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: "10.0.0" | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
macos-nvmrc: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v | ||
macos-canary: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: ./ | ||
with: | ||
node-version: latest | ||
node-mirror: https://nodejs.org/download/v8-canary/ | ||
- name: Check | ||
run: | | ||
node -v | ||
npm -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,65 @@ | ||
const child_process = require("child_process"); | ||
const path = require("path"); | ||
const core = require("@actions/core"); | ||
const version = core.getInput("node-version"); | ||
const mirror = core.getInput("node-mirror"); | ||
const child = child_process.spawn("bash", [ "install.sh", version, mirror ], { cwd: __dirname }); | ||
const stdout = []; | ||
child.stdout.on("data", out => { | ||
stdout.push(out); | ||
process.stdout.write(out); | ||
}); | ||
child.stderr.on("data", out => { | ||
process.stderr.write(out); | ||
}); | ||
child.on("close", code => { | ||
if (code !== 0) throw Error("installation failed with " + code); | ||
const out = Buffer.concat(stdout).toString("utf8"); | ||
var nodePath; | ||
var npmPath; | ||
try { | ||
nodePath = /SETUP_NODE_NVM_NODE: ([^\n]+)/.exec(out)[1]; | ||
npmPath = /SETUP_NODE_NVM_NPM: ([^\n]+)/.exec(out)[1]; | ||
} catch (e) { | ||
throw Error("missing node/npm path in output"); | ||
const semver = require("semver"); | ||
const nv = require("@pkgjs/nv"); | ||
|
||
// Utilize @pkgjs/nv to resolve before forwarding to nvm / nvm-windows | ||
async function resolveVersion(version, mirror) { | ||
if (version) { | ||
let query = version; | ||
switch (query) { | ||
case "node": { query = "current"; break; } | ||
case "lts/*": { query = "lts_latest"; break; } | ||
case "latest": { query = "all"; break; } | ||
} | ||
const versions = await nv(query, { mirror }); | ||
if (versions.length) { | ||
versions.sort((a, b) => semver.rcompare(a.version, b.version)); | ||
return versions[0].version; | ||
} | ||
} | ||
console.log("Using node: " + nodePath); | ||
core.addPath(path.dirname(nodePath)); | ||
console.log("Using npm: " + npmPath); | ||
core.addPath(path.dirname(npmPath)); | ||
}); | ||
return version; | ||
} | ||
|
||
(async () => { | ||
let mirror = core.getInput("node-mirror") || "https://nodejs.org/dist/"; | ||
let version = await resolveVersion(core.getInput("node-version"), mirror); | ||
if (process.platform == "win32") { | ||
runScript("powershell", ".\\install.ps1", version, mirror); | ||
} else { | ||
runScript("bash", "install.sh", version, mirror); | ||
} | ||
})(); | ||
|
||
function runScript(shell, script, version, mirror) { | ||
const child = child_process.spawn(shell, [ script, version, mirror ], { cwd: __dirname }); | ||
const stdout = []; | ||
child.stdout.on("data", out => { | ||
stdout.push(out); | ||
process.stdout.write(out); | ||
}); | ||
child.stderr.on("data", out => { | ||
process.stderr.write(out); | ||
}); | ||
child.on("close", code => { | ||
if (code !== 0) throw Error("installation failed with " + code); | ||
const out = Buffer.concat(stdout).toString("utf8"); | ||
var nvmPath; | ||
var nodePath; | ||
var npmPath; | ||
try { | ||
nvmPath = /SETUP_NODE_NVM_NVM: ([^\n]+)/.exec(out)[1]; | ||
nodePath = /SETUP_NODE_NVM_NODE: ([^\n]+)/.exec(out)[1]; | ||
npmPath = /SETUP_NODE_NVM_NPM: ([^\n]+)/.exec(out)[1]; | ||
} catch (e) { | ||
throw Error("missing nvm/node/npm path in output"); | ||
} | ||
console.log("Using nvm: " + nvmPath); | ||
core.addPath(path.dirname(nvmPath)); | ||
console.log("Using node: " + nodePath); | ||
core.addPath(path.dirname(nodePath)); | ||
console.log("Using npm: " + npmPath); | ||
core.addPath(path.dirname(npmPath)); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$NVM_HOME="$((Get-Location).Path)\mynvm" | ||
$env:NVM_HOME=$NVM_HOME | ||
$env:NVM_PATH=$NVM_HOME | ||
$env:NVM_SYMLINK="$NVM_HOME\nodejs" | ||
$env:PATH=$env:PATH + ";$NVM_HOME" | ||
Invoke-WebRequest -Uri https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip -OutFile nvm.zip | ||
Expand-Archive nvm.zip -DestinationPath "$NVM_HOME" | ||
New-Item -Path "$NVM_HOME\settings.txt" -ItemType File | ||
nvm.exe root $NVM_HOME | ||
nvm.exe node_mirror $args[1] | ||
nvm.exe install $args[0] | ||
nvm.exe use $args[0] | ||
echo "SETUP_NODE_NVM_NVM: $NVM_HOME" | ||
echo "SETUP_NODE_NVM_NODE: $NVM_HOME\nodejs\node.exe" | ||
echo "SETUP_NODE_NVM_NPM: $NVM_HOME\nodejs\npm.cmd" |
Oops, something went wrong.