Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first pass at {pre,,post}install hooks, test not yet passing

  • Loading branch information...
commit 0ed418eb3552a9af95d57086597e8f6f2f27194c 1 parent 8776e37
James Halliday authored
Showing with 33 additions and 1 deletion.
  1. +33 −1 lib/spawn.js
34 lib/spawn.js
View
@@ -18,7 +18,39 @@ module.exports = function (commit, env, cb) {
start = { 'index': start };
}
- runServers(start);
+ var before = [
+ pkg.scripts && pkg.scripts.preinstall,
+ pkg.scripts && pkg.scripts.install,
+ pkg.scripts && pkg.scripts.postinstall
+ ].filter(Boolean);
+
+ (function next () {
+ if (before.length === 0) return runServers(start);
+
+ var cmd = before.shift();
+ if (!Array.isArray(cmd)) cmd = parseQuote(cmd);
+ var ps = commit.spawn(cmd, { env: env });
+ var output = '';
+ ps.stdout.on('data', function (buf) { output += buf });
+ ps.stderr.on('data', function (buf) { output += buf });
+
+ var to = setTimeout(function () {
+ ps.removeListener('exit', onexit);
+ cb('install took too long, aborting');
+ }, 2 * 60 * 1000);
+
+ ps.on('exit', onexit);
+ function onexit (code) {
+ if (code !== 0) {
+ cb([
+ 'non-zero exit code ', code,
+ ' from command: ', cmd.join(' '), '\n',
+ output
+ ].join(''));
+ }
+ else next()
+ }
+ })();
});
function runServers (start) {
Please sign in to comment.
Something went wrong with that request. Please try again.