Refactoring: reorganize files between client and server + initiate deployment

This commit is contained in:
2015-11-05 07:58:55 +00:00
parent fd483c0d27
commit 42e5a06750
11 changed files with 177 additions and 59 deletions

View File

@@ -0,0 +1,36 @@
var exec = Npm.require('child_process').exec,
execSync = function(cmd, options, stdoutHandler, stderrHandler) {
exec(cmd,
options,
Meteor.bindEnvironment(
function(error, stdout, stderr) {
if( stdout != '' ) {
stdoutHandler(stdout);
}
if( stderr != '' ) {
stderrHandler(stderr);
}
}
)
);
};
var CommandRunner = {
run: function( script, deployment, stdout, stderr, counter, callback ) {
var command = script[command].cmd.replace('%ROOT_CWD%', DEPLOYMENT_FOLDER).replace('%CWD%', deployment._id),
options = script[command].options;
options.cwd.replace('%ROOT_CWD%', DEPLOYMENT_FOLDER).replace('%CWD%', deployment._id);
execSync(command, options, stdout, stderr, function() {
counter++;
if( counter > script.length ) {
if( callback ) {
callback();
}
} else {
CommandRunner.run(script, deployment, stdout, stderr, counter, callback);
}
});
}
}