Created
October 28, 2014 19:57
-
-
Save nullstyle/017f4f896d445d37bebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var spawn = require('child_process').spawn; | |
var _ = require("lodash"); | |
gulp.task("test", ['db:ensure-created-test'], function() { | |
log("running tests here"); | |
}); | |
gulp.task("db:ensure-created", function() { | |
log("creating db"); | |
}); | |
gulp.task("db:ensure-created-test", function(done) { | |
if(process.env.NODE_ENV === 'test') { | |
gulp.start("db:ensure-created", done); | |
} else { | |
log("spawning child process to create db"); | |
var options = { | |
stdio: 'inherit', | |
env: _.defaults({NODE_ENV: "test"}, process.env), | |
cwd: process.cwd | |
}; | |
spawn("gulp", ["db:ensure-created-test"], options).once('close', done); | |
} | |
}); | |
function log(message) { | |
var nodeEnv = process.env.NODE_ENV || "dev "; | |
console.log(nodeEnv + " PID:" + process.pid + " - " + message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment