Skip to content

Commit 346e64e

Browse files
committed
make it work
1 parent fc4ece4 commit 346e64e

File tree

13 files changed

+558
-16
lines changed

13 files changed

+558
-16
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
on: [push,pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@master
8+
- uses: dcodeIO/setup-node-nvm@master
9+
with:
10+
node-version: node
11+
- name: Check
12+
run: |
13+
which node
14+
node -v
15+
which npm
16+
npm -v

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
node_modules/
21
package-lock.json

index.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
const child_process = require("child_process");
2+
const path = require("path");
23
const core = require("@actions/core");
34
const version = core.getInput("node-version");
45
const mirror = core.getInput("node-mirror");
5-
var child = child_process.spawnSync("bash", [ "install.sh", version, mirror ], { stdio: "inherit", encoding: "utf8" });
6-
if (child.status != 0) throw Error("installation failed with " + child.status);
7-
var nodePath;
8-
var npmPath;
9-
try {
10-
nodePath = /SETUP_NODE_NVM_NODE: ([^\n]+)/.exec(child.stdout)[1];
11-
npmPath = /SETUP_NODE_NVM_NPM: ([^\n]+)/.exec(child.stdout)[1];
12-
} catch (e) {
13-
throw Error("missing node/npm path in output");
14-
}
15-
console.log("Using node: " + nodePath);
16-
core.setPath(nodePath);
17-
console.log("Using npm: " + npmPath);
18-
core.setPath(npmPath);
6+
const child = child_process.spawn("bash", [ "install.sh", version, mirror ], { cwd: __dirname });
7+
const stdout = [];
8+
child.stdout.on("data", out => {
9+
stdout.push(out);
10+
process.stdout.write(out);
11+
});
12+
child.stderr.on("data", out => {
13+
process.stderr.write(out);
14+
});
15+
child.on("close", code => {
16+
if (code !== 0) throw Error("installation failed with " + code);
17+
const out = Buffer.concat(stdout).toString("utf8");
18+
var nodePath;
19+
var npmPath;
20+
try {
21+
nodePath = /SETUP_NODE_NVM_NODE: ([^\n]+)/.exec(out)[1];
22+
npmPath = /SETUP_NODE_NVM_NPM: ([^\n]+)/.exec(out)[1];
23+
} catch (e) {
24+
throw Error("missing node/npm path in output");
25+
}
26+
console.log("Using node: " + nodePath);
27+
core.addPath(path.dirname(nodePath));
28+
console.log("Using npm: " + npmPath);
29+
core.addPath(path.dirname(npmPath));
30+
});

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
44
export NVM_DIR="$HOME/.nvm"
55
export NVM_NODEJS_ORG_MIRROR="$2"
66
chmod +x "$NVM_DIR/nvm.sh"
7-
"$NVM_DIR/nvm.sh" --no-use
7+
. "$NVM_DIR/nvm.sh" --no-use
88
nvm install $1
99
nvm use $1
1010
npm -g install npm

node_modules/@actions/core/LICENSE.md

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/README.md

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/core.d.ts

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)