From 49cb6323749bba25a8da80ff1aa54a2747fb090b Mon Sep 17 00:00:00 2001 From: Joseph Dykstra Date: Mon, 23 Mar 2015 10:14:55 -0500 Subject: [PATCH] write to outfile and skip rename on windows --- bin/cmd.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index bd0a1b1..d415259 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -6,6 +6,7 @@ var path = require('path'); var fromArgs = require('./args.js'); var w = fromArgs(process.argv.slice(2)); +var usingWindows = (process.platform === 'win32'); w.setMaxListeners(Infinity); var outfile = w.argv.o || w.argv.outfile; @@ -28,20 +29,25 @@ function bundle () { if (err) console.error(err); }) }); - wb.pipe(fs.createWriteStream(dotfile)); + wb.pipe(fs.createWriteStream(usingWindows ? outfile : dotfile)); var bytes, time; w.on('bytes', function (b) { bytes = b }); w.on('time', function (t) { time = t }); wb.on('end', function () { + if (usingWindows) return logVerboseEnd(); fs.rename(dotfile, outfile, function (err) { if (err) return console.error(err); - if (verbose) { - console.error(bytes + ' bytes written to ' + outfile - + ' (' + (time / 1000).toFixed(2) + ' seconds)' - ); - } + logVerboseEnd(); }); }); + + function logVerboseEnd () { + if (verbose) { + console.error(bytes + ' bytes written to ' + outfile + + ' (' + (time / 1000).toFixed(2) + ' seconds)' + ); + } + } }