pulsar/script/bootstrap
Cheng Zhao 645fc1511a Do not add parameter in shebang string.
On Linux "#!/usr/bin/env node --harmony_collections" is unfortunately
not recognized by system.
2014-03-25 15:40:43 +08:00

58 lines
2.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
var nodeMinorVersion = process.versions.node.split('.')[1]
if (nodeMinorVersion !== '10') {
console.warn("You must run script/bootstrap and script/build with node v0.10.x");
process.exit(1);
}
var safeExec = require('./utils/child-process-wrapper.js').safeExec;
var fs = require('fs');
var path = require('path');
// Executes an array of commands one by one.
function executeCommands(commands, done, index) {
index = (index == undefined ? 0 : index);
if (index < commands.length) {
var command = commands[index];
var options = null;
if (typeof command !== 'string') {
options = command.options;
command = command.command;
}
safeExec(command, options, executeCommands.bind(this, commands, done, index + 1));
} else
done(null);
}
var apmVendorPath = path.resolve(__dirname, '..', 'vendor', 'apm');
var apmInstallPath = path.resolve(__dirname, '..', 'apm');
if (!fs.existsSync(apmInstallPath))
fs.mkdirSync(apmInstallPath);
if (!fs.existsSync(path.join(apmInstallPath, 'node_modules')))
fs.mkdirSync(path.join(apmInstallPath, 'node_modules'));
var apmPath = 'apm/node_modules/atom-package-manager/bin/apm'
var apmFlags = process.env.JANKY_SHA1 || process.argv.indexOf('--no-color') !== -1 ? '--no-color' : '';
var npmPath = path.resolve(__dirname, '..', 'build', 'node_modules', '.bin', 'npm');
var npmFlags = ' --userconfig=' + path.resolve('.npmrc') + ' ';
var packagesToDedupe = ['fs-plus', 'humanize-plus', 'oniguruma', 'roaster', 'season'];
var echoNewLine = process.platform == 'win32' ? 'echo.' : 'echo';
var commands = [
'git submodule --quiet sync',
'git submodule --quiet update --recursive --init',
{command: 'npm' + npmFlags + 'install --quiet', options: {cwd: path.resolve(__dirname, '..', 'build'), ignoreStdout: true}},
{command: npmPath + npmFlags + 'install --quiet', options: {cwd: apmVendorPath, ignoreStdout: true}},
{command: npmPath + npmFlags + 'install --quiet ' + apmVendorPath, options: {cwd: apmInstallPath, ignoreStdout: true}},
echoNewLine,
apmPath + ' clean ' + apmFlags,
apmPath + ' install --quiet ' + apmFlags,
apmPath + ' dedupe --quiet ' + apmFlags + ' ' + packagesToDedupe.join(' '),
];
process.chdir(path.dirname(__dirname));
executeCommands(commands, process.exit);