Only spawn removed command for paths that exist

Prevents errors being logged when trying to remove folders that
don't exist on Windows.
This commit is contained in:
Kevin Sawicki 2014-06-06 08:56:13 -07:00
parent 776e8a308c
commit 3b6711d83d

View File

@ -1,5 +1,6 @@
#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var fs = require('fs');
var path = require('path');
var os = require('os');
@ -30,8 +31,14 @@ var run = function() {
var next = commands.shift();
if (!next)
process.exit(0);
if (Array.isArray(next))
next = removeCommand + path.resolve.apply(path.resolve, next);
if (Array.isArray(next)) {
var pathToRemove = path.resolve.apply(path.resolve, next);
if (fs.existsSync(pathToRemove))
next = removeCommand + pathToRemove;
else
run();
}
cp.safeExec(next, run);
};
run();