pulsar/script/cibuild
2013-12-18 11:12:38 -08:00

47 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var fs = require('fs');
var path = require('path');
process.chdir(path.dirname(__dirname));
if (process.platform == 'linux')
throw new Error('cibuild can not run on linux yet!');
var homeDir = process.platform == 'win32' ? process.env.USERPROFILE : process.env.HOME;
function readEnvironmentVariables() {
var credentialsPath = '/var/lib/jenkins/config/atomcredentials';
try {
var credentials = fs.readFileSync(credentialsPath, 'utf8');
var lines = credentials.trim().split('\n');
for (i in lines) {
var parts = lines[i].split('=');
var key = parts[0].trim();
var value = parts[1].trim().substr(1, parts[1].length - 2);
process.env[key] = value;
}
} catch(error) { }
}
readEnvironmentVariables();
cp.safeExec.bind(global, 'node script/bootstrap', function(error) {
if (error)
process.exit(1);
var async = require('async');
var gruntPath = path.join('node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : '');
process.stdout.write('0')
async.series([
require('rimraf').bind(global, path.join(homeDir, '.atom')),
process.stdout.write.bind(global,'a'),
cp.safeExec.bind(global, 'git clean -dff'),
process.stdout.write.bind(global, 'b', gruntPath),
cp.safeExec.bind(global, gruntPath + ' ci --stack --no-color'),
process.stdout.write.bind(global, 'c'),
cp.safeExec.bind(global, 'node_modules/.bin/coffee script/upload-release'),
process.stdout.write.bind(global, 'd')
], function(error) {
process.exit(error ? 1 : 0);
});
})();