Skip to content

Commit

Permalink
Add github actions (#6)
Browse files Browse the repository at this point in the history
* Add github actions

* Update test output

* Add catch for node 8

* Add node 6

* Remove async

* Add node 4

* Add node 0.12

* Remove node 0.12
  • Loading branch information
janniks authored Apr 21, 2020
1 parent 7a7c260 commit 35c9b9f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [4.x, 6.x, 8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm test
2 changes: 1 addition & 1 deletion postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function fileExists(path) {
try {
fs.accessSync(path);
return true;
} catch {
} catch (e) {
return false;
}
}
Expand Down
11 changes: 4 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,22 @@ function execute(command) {
"npm pack ../..",
`npm install --save ${package.name}-${package.version}.tgz`,
"node index.js",
].forEach(async (command) => {
].forEach((command) => {
try {
process.stdout.write(` ${command}`);
process.stdout.cursorTo(0);

const result = execute(command);

if (result.error) throw result.error;

if (result.status != 0) {
console.log(`\nstdout:\n${result.stdout}`);
console.log(`stdout:\n${result.stdout}`);
console.error(`stderr:\n${result.stderr}`);
throw "Bad status code";
}

process.stdout.clearLine();
console.log(`✓ ${command}`);
} catch (error) {
console.error(`\n${error.stack ? error.stack : error}`);
console.log(`⨯ ${command}`);
console.error(`${error.stack ? error.stack : error}`);
process.exit(1);
}
});
Expand Down

0 comments on commit 35c9b9f

Please sign in to comment.