Skip to content

Commit

Permalink
Modified API for --tarball support.
Browse files Browse the repository at this point in the history
  • Loading branch information
InconceivableDuck committed Jan 13, 2014
1 parent 5870d7a commit abbe670
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 35 deletions.
6 changes: 3 additions & 3 deletions cli/demeteorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ var program = require('commander'),

program
.version(require('../package.json').version)
.option('-o, --output <path>', 'Output folder for converted application. Defaults to ./.demeteorized')
.option('-o, --output <path>', 'Output folder for converted application. Defaults to ./.demeteorized.')
.option('-n, --node_version <version>', 'The required version of node [v0.10.22]', 'v0.10.22')
.option('-r, --release <version>', 'Sets the Meteor version. Defaults to latest installed.')
.option('-t --tarball', 'Creates a tarball instead of a directory containing the converted application')
.option('-r, --release <version>', 'The Meteor version. Defaults to latest installed.')
.option('-t --tarball <path>', 'Output tarball path. If specified, creates a tar.gz of demeteorized application instead of directory.')
.parse(process.argv);

var output = program.output;
Expand Down
48 changes: 16 additions & 32 deletions lib/demeteorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,63 +348,47 @@ Demeteorizer.prototype.deleteBundle = function(callback) {
};

//--------------------------------------------------------------------------------------------------

Demeteorizer.prototype.createTarball = function(tarball, output, callback) {

if(!tarball) {
callback();
return;
return callback();
}

var self = this;

self.emit('progress', 'Creating tarball.');

exec('mv ' + escapePath(output) + ' bundle', {cwd: path.join(escapePath(output), '../')}, function(err, stdout, stderr) {
var cmd = 'tar czPf ' + escapePath(tarball) + ' -C ' + escapePath(output) + ' .';
console.log(cmd);

exec(cmd, function(err, stdout, stderr) {

if(stdout) {
self.emit('progress', stdout);
}

if(err) {
return callback(err);
}

if(stderr) {
return callback(stderr);
}

exec('tar czfP ' + escapePath(output) + ' bundle', {cwd: path.join(escapePath(output), '../')}, function(err, stdout, stderr) {

if(stdout) {
self.emit('progress', stdout);
}

if(err) {
return callback(err);
}

if(stderr) {
return callback(stderr);
}


callback();
});


callback();
});



}


//--------------------------------------------------------------------------------------------------

Demeteorizer.prototype.deleteDirectory = function(tarball, output, callback) {

if(!tarball) {
callback();
return;
return callback();
}

this.emit('progress', 'Deleting bundle directory');
this.emit('progress', 'Deleting bundle directory.');

exec('rm -rf ' + path.join(escapePath(output), '../bundle'), function(err, stdout, stderr) {
exec('rm -rf ' + escapePath(output), function(err, stdout, stderr) {
if(err) {
return callback(err);
}
Expand Down

0 comments on commit abbe670

Please sign in to comment.