Skip to content

Commit

Permalink
Fix EPERM error on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelcabral committed Dec 27, 2014
1 parent e2c9bfb commit f3f61b4
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,25 @@ w.on('update', bundle);
bundle();

function bundle () {
var wb = w.bundle();
wb.on('error', function (err) {
console.error(String(err));
fs.writeFile(outfile, 'console.error('+JSON.stringify(String(err))+')', function(err) {
if (err) console.error(err);
})
});
wb.pipe(fs.createWriteStream(dotfile));

var bytes, time;
w.on('bytes', function (b) { bytes = b });
w.on('time', function (t) { time = t });

wb.on('end', function () {
fs.rename(dotfile, outfile, function (err) {
if (err) return console.error(err);
w.bundle(function(err, buf) {
if(err) {
console.error(String(err));
fs.writeFile(outfile, 'console.error('+JSON.stringify(String(err))+')', function(err) {
if (err) console.error(err);
})
}
else {
fs.writeFile(outfile, buf, function(err) {
if (err) console.error(err);
})
if (verbose) {
console.error(bytes + ' bytes written to ' + outfile
console.error(buf.length + ' bytes written to ' + outfile
+ ' (' + (time / 1000).toFixed(2) + ' seconds)'
);
}
});
}
});

var time = 0;
w.on('time', function (t) { time = t });
}

0 comments on commit f3f61b4

Please sign in to comment.