Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fail CI if native addon build fails #65

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions build-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const fs = require('fs');
const childProcess = require('child_process');

const EXIT_SUCCESS = 0;
const EXIT_FAIL = 1;

const nodeGyp = childProcess.spawn('node-gyp', ['rebuild'], { shell: true });
const errorLines = [];

nodeGyp.on('error', showWarning);
nodeGyp.on('error', () => {
handleBuildError(EXIT_FAIL);
});

nodeGyp.stdout.pipe(process.stdout);

Expand All @@ -23,12 +26,16 @@ nodeGyp.on('exit', (code) => {
fs.writeFileSync('builderror.log', errorLines.join('\n'));
}
if (code !== EXIT_SUCCESS) {
showWarning();
handleBuildError(code);
}
process.exit();
});

function showWarning() {
console.warn('Could not build JSTP native extensions, ' +
'JavaScript implementation will be used instead.');
function handleBuildError(code) {
if (process.env.TRAVIS) {
process.exit(code);
} else {
console.warn('Could not build JSTP native extensions, ' +
'JavaScript implementation will be used instead.');
}
}