From 3b1b82dc40235a55e6d8121206d41e45fa2b8ec7 Mon Sep 17 00:00:00 2001 From: Craig Condon Date: Mon, 14 Oct 2013 10:40:46 -0700 Subject: [PATCH] cleanup --- lib/index.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index 51232a5..5df53b6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -98,12 +98,6 @@ function downloadNode(version, temp, next) { var tmpPath = path.join(temp, "node-" + version + ".tar.gz"), srcDr = tmpPath.replace(/\.tar.gz$/, ""); - try { - - mkdirp.sync(path.dirname(tmpPath)); - - //an error will usually occur when the dir already exists. - } catch(e) { } step( @@ -133,11 +127,14 @@ function downloadNode(version, temp, next) { //source dir exists? if(fs.existsSync(srcDr)) return this(); - console.log("unzipping node source"); + try { + mkdirp.sync(srcDr); + } catch(e) { + } //TODO - use native zlib library for this - exec(sprintf("tar -xf '%s'", tmpPath), { cwd: path.dirname(tmpPath) }, this); + exec(sprintf("tar -xf '%s' -C '%s'", tmpPath, srcDr), { cwd: path.dirname(tmpPath) }, this); }, /** @@ -153,16 +150,23 @@ function downloadNode(version, temp, next) { */ function() { + + console.log(srcDr) + + vDir = path.join(srcDr, fs.readdirSync(srcDr).filter(function(dir) { + return !/^\./.test(dir); + }).pop()); + next(null, { //the directory to the node.js file - dir: srcDr, + dir: vDir, - releasePath: path.join(srcDr, "out/Release/node"), + releasePath: path.join(vDir, "out/Release/node"), //makes node.js make: function(next) { - var configure = spawn('./configure', [], { cwd: srcDr }); + var configure = spawn('./configure', [], { cwd: vDir }); configure.stdout.on('data', function(data) { process.stdout.write(data.toString()); }); @@ -170,7 +174,7 @@ function downloadNode(version, temp, next) { process.stderr.write(data.toString()); }); configure.on('close', function() { - var make = spawn('make', [], { cwd: srcDr }); + var make = spawn('make', [], { cwd: vDir }); make.stdout.on('data', function(data) { process.stdout.write(data.toString()); });