pulsar/script/bootstrap
Cheng Zhao e4400c648d Revert "Run apm from node_modules"
This reverts commit 8742f6c06c.

The `node_modules/.bin/apm` is a bash script not a js script, so on
Windows `node node_modules/.bin/apm` would fail with:

```
C:\cygwin\home\zcbenz\codes\atom\node_modules\.bin\apm:2
basedir=`dirname "$0"`
        ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
```
2013-10-30 10:51:06 +08:00

32 lines
1020 B
JavaScript
Executable File

#!/usr/bin/env node
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)
safeExec(commands[index], executeCommands.bind(this, commands, done, index + 1));
else
done(null);
}
// Join multiple commands into one line.
function joinCommands() {
var commandSeparator = process.platform == 'win32' ? '&' : ';';
return Array.prototype.slice.call(arguments, 0).join(commandSeparator);
}
var echoNewLine = process.platform == 'win32' ? 'echo.' : 'echo';
var commands = [
'git submodule --quiet sync',
'git submodule --quiet update --recursive --init',
joinCommands('cd vendor/apm', 'npm install --silent .'),
'npm install --silent vendor/apm',
echoNewLine,
'node vendor/apm/bin/apm install --silent',
];
process.chdir(path.dirname(__dirname));
executeCommands(commands, process.exit);