2014-03-20 18:10:11 +04:00
|
|
|
#!/usr/bin/env node
|
2013-10-14 12:29:26 +04:00
|
|
|
var cp = require('./utils/child-process-wrapper.js');
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
2012-08-31 21:43:21 +04:00
|
|
|
|
2013-10-14 12:29:26 +04:00
|
|
|
process.chdir(path.dirname(__dirname));
|
2013-06-21 02:26:00 +04:00
|
|
|
|
2013-10-14 12:29:26 +04:00
|
|
|
var homeDir = process.platform == 'win32' ? process.env.USERPROFILE : process.env.HOME;
|
2013-06-21 02:41:23 +04:00
|
|
|
|
2014-01-14 22:36:21 +04:00
|
|
|
function loadEnvironmentVariables(filePath) {
|
2013-10-27 01:59:46 +04:00
|
|
|
try {
|
2014-01-14 22:36:21 +04:00
|
|
|
var lines = fs.readFileSync(filePath, 'utf8').trim().split('\n');
|
2013-10-27 01:59:46 +04:00
|
|
|
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;
|
2013-10-14 12:29:26 +04:00
|
|
|
}
|
2014-06-14 02:05:36 +04:00
|
|
|
} catch(error) {
|
2014-06-14 02:12:06 +04:00
|
|
|
console.error("Failed to load environment variables: " + filePath, error.code);
|
2014-06-14 02:05:36 +04:00
|
|
|
}
|
2013-10-14 12:29:26 +04:00
|
|
|
}
|
2013-10-04 08:42:15 +04:00
|
|
|
|
2014-01-14 22:36:21 +04:00
|
|
|
function readEnvironmentVariables() {
|
2014-06-14 02:40:46 +04:00
|
|
|
if (process.platform === 'win32')
|
2014-06-14 02:25:13 +04:00
|
|
|
loadEnvironmentVariables(path.resolve('/jenkins/config/atomcredentials'));
|
2014-09-04 02:23:52 +04:00
|
|
|
else if (process.platform === 'darwin') {
|
2014-06-14 02:05:36 +04:00
|
|
|
loadEnvironmentVariables('/var/lib/jenkins/config/atomcredentials');
|
|
|
|
loadEnvironmentVariables('/var/lib/jenkins/config/xcodekeychain');
|
|
|
|
}
|
2014-01-14 22:36:21 +04:00
|
|
|
}
|
|
|
|
|
2015-02-11 22:29:56 +03:00
|
|
|
function removeNodeModules() {
|
|
|
|
try {
|
|
|
|
require('fs-plus').removeSync(path.resolve(__dirname, '..', 'node_modules'));
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error.message);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-27 02:03:21 +04:00
|
|
|
readEnvironmentVariables();
|
2015-02-11 22:29:56 +03:00
|
|
|
removeNodeModules();
|
2014-05-29 05:31:20 +04:00
|
|
|
cp.safeExec.bind(global, 'npm install npm', {cwd: path.resolve(__dirname, '..', 'build')}, function() {
|
2014-05-27 21:25:23 +04:00
|
|
|
cp.safeExec.bind(global, 'node script/bootstrap', function(error) {
|
|
|
|
if (error)
|
|
|
|
process.exit(1);
|
|
|
|
require('fs-plus').removeSync.bind(global, path.join(homeDir, '.atom'))
|
|
|
|
var async = require('async');
|
|
|
|
var gruntPath = path.join('build', 'node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : '');
|
|
|
|
var tasks = [
|
|
|
|
cp.safeExec.bind(global, 'git clean -dff'),
|
|
|
|
cp.safeExec.bind(global, gruntPath + ' ci --gruntfile build/Gruntfile.coffee --stack --no-color'),
|
|
|
|
]
|
|
|
|
async.series(tasks, function(error) {
|
|
|
|
process.exit(error ? 1 : 0);
|
|
|
|
});
|
|
|
|
})();
|
2013-10-27 02:07:20 +04:00
|
|
|
})();
|