mirror of
https://github.com/atom/atom.git
synced 2026-01-15 01:48:15 -05:00
The first time you bootstrap, all the build modules and apm are installed. Previously this was showing no output so it was unclear whether things are hung or now. This will also help easily identify which stage of the build npm and node-gyp errors are occurring.
63 lines
2.3 KiB
JavaScript
Executable File
63 lines
2.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var fs = require('fs');
|
|
var verifyRequirements = require('./utils/verify-requirements');
|
|
var safeExec = require('./utils/child-process-wrapper.js').safeExec;
|
|
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];
|
|
if (command.message)
|
|
console.log(command.message);
|
|
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);
|
|
}
|
|
|
|
function bootstrap() {
|
|
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 = path.resolve(__dirname, '..', '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 initialNpmCommand = fs.existsSync(npmPath) ? npmPath : 'npm';
|
|
var npmFlags = ' --userconfig=' + path.resolve('.npmrc') + ' ';
|
|
|
|
var packagesToDedupe = ['fs-plus', 'humanize-plus', 'oniguruma', 'roaster', 'season', 'grim'];
|
|
|
|
var commands = [
|
|
{command: initialNpmCommand + npmFlags + 'install --quiet', message: 'Installing build modules...', options: {cwd: path.resolve(__dirname, '..', 'build'), ignoreStdout: true}},
|
|
{command: npmPath + npmFlags + 'install --quiet', message: 'Installing apm...', options: {cwd: apmInstallPath, ignoreStdout: true}},
|
|
apmPath + ' clean ' + apmFlags,
|
|
apmPath + ' install --quiet ' + apmFlags,
|
|
apmPath + ' dedupe --quiet ' + apmFlags + ' ' + packagesToDedupe.join(' '),
|
|
];
|
|
|
|
process.chdir(path.dirname(__dirname));
|
|
executeCommands(commands, process.exit);
|
|
}
|
|
|
|
verifyRequirements(function(error, successMessage) {
|
|
if (error) {
|
|
console.log(error);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(successMessage);
|
|
bootstrap();
|
|
});
|