Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
fixed "must not be in the source directory"
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 11, 2012
1 parent 5cdcdd6 commit 1f09e6e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/jscover.js
Expand Up @@ -34,9 +34,15 @@ module.exports = function jscover(source, target, options, callback) {
target = target || '';
options = options || [];
var tmpName = '__cov__' + Date.now();
var tmpTargetDir = path.join(path.dirname(target), tmpName);
var tmpdir = process.env.TMPDIR || '/tmp';
var tmpTargetDir = path.join(tmpdir, tmpName);
var tmpTarget = path.join(tmpTargetDir, path.basename(target));

var cleanup = function () {
fse.removeSync(tmpTargetDir);
fse.removeSync(path.join(target, tmpName));
};

var cmd = JSCoverCommand;
if (options && options.length > 0) {
cmd += ' ' + options.join(' ');
Expand All @@ -59,6 +65,7 @@ module.exports = function jscover(source, target, options, callback) {
}
if (err) {
debug(err, stderr);
cleanup();
return callback(err, output);
}

Expand Down Expand Up @@ -88,10 +95,10 @@ module.exports = function jscover(source, target, options, callback) {
}
}
}, function end() {
fse.removeSync(tmpTargetDir);
fse.removeSync(path.join(target, tmpName));
cleanup();
callback();
}, function error(err, errPath) {
cleanup();
console.error('%s error: %s', errPath, err);
callback(err);
});
Expand Down

0 comments on commit 1f09e6e

Please sign in to comment.