travis script that will download the latest build from a branch or a release based on the config it receives.
96 lines
2.1 KiB
JavaScript
96 lines
2.1 KiB
JavaScript
var cp = require('child_process');
|
|
var async = require('async');
|
|
var argv = require('optimist')
|
|
.options({
|
|
force: {
|
|
alias: 'f',
|
|
default: false,
|
|
boolean: true
|
|
},
|
|
verbose: {
|
|
alias: 'v',
|
|
default: false,
|
|
boolean: true
|
|
},
|
|
api: {
|
|
default: true,
|
|
boolean: true
|
|
},
|
|
tests: {
|
|
default: true,
|
|
boolean: true
|
|
},
|
|
es_branch: {
|
|
default: 'master',
|
|
string: true,
|
|
alias: 'b'
|
|
}
|
|
});
|
|
|
|
if (process.env.npm_config_argv) {
|
|
// when called by NPM
|
|
argv = argv.parse(JSON.parse(process.env.npm_config_argv).original);
|
|
} else {
|
|
// when called directly
|
|
argv = argv.argv;
|
|
}
|
|
|
|
if (!argv.force && process.env.FORCE || process.env.FORCE_GEN) {
|
|
argv.force = argv.f = process.env.FORCE || process.env.FORCE_GEN;
|
|
}
|
|
|
|
var branch = argv.es_branch;
|
|
// branch can be prefixed with = or suffixed with _nightly
|
|
if (branch.indexOf) {
|
|
['='].forEach(function removePrefix(pref) {
|
|
if (branch.indexOf(pref) === 0) {
|
|
branch = branch.substring(pref.length);
|
|
}
|
|
});
|
|
|
|
['_nightly'].forEach(function removeSuffix(suf) {
|
|
if (branch.indexOf(suf) === branch.length - suf.length) {
|
|
branch = branch.substr(0, branch.length - suf.length);
|
|
}
|
|
});
|
|
}
|
|
|
|
var stdio = [
|
|
'ignore',
|
|
argv.verbose ? process.stdout : 'ignore',
|
|
process.stderr
|
|
];
|
|
|
|
async.series([
|
|
function (done) {
|
|
cp.spawn('git', ['submodule', 'update', '--init'], {
|
|
stdio: stdio
|
|
}).on('exit', function (status) {
|
|
done(status ? new Error('Unable to init submodules.') : void 0);
|
|
});
|
|
},
|
|
function (done) {
|
|
// checkout branch and clean it
|
|
cp.spawn('git', ['submodule', 'foreach', 'git checkout origin/' + branch + ' && git clean -f'], {
|
|
stdio: stdio
|
|
}).on('exit', function (status) {
|
|
done(status ? new Error('Unable to checkout ' + branch) : void 0);
|
|
});
|
|
},
|
|
function (done) {
|
|
var tasks = [];
|
|
|
|
if (argv.api) {
|
|
tasks.push(require('./js_api'));
|
|
}
|
|
if (argv.tests) {
|
|
tasks.push(require('./yaml_tests'));
|
|
}
|
|
|
|
async.parallel(tasks, done);
|
|
}
|
|
], function (err) {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
}); |