mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Simplify removeSource
and make it synchronous
This commit is contained in:
parent
81d8224b9a
commit
caafafcf4d
2 changed files with 14 additions and 15 deletions
|
@ -375,22 +375,21 @@
|
|||
};
|
||||
|
||||
removeSource = function(source, base, removeJs) {
|
||||
var index, jsPath;
|
||||
var err, index, jsPath;
|
||||
index = sources.indexOf(source);
|
||||
sources.splice(index, 1);
|
||||
sourceCode.splice(index, 1);
|
||||
if (removeJs && !opts.join) {
|
||||
jsPath = outputPath(source, base);
|
||||
return fs.exists(jsPath, function(itExists) {
|
||||
if (itExists) {
|
||||
return fs.unlink(jsPath, function(err) {
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
return timeLog("removed " + source);
|
||||
});
|
||||
try {
|
||||
fs.unlinkSync(jsPath);
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
return timeLog("removed " + source);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -259,11 +259,11 @@ removeSource = (source, base, removeJs) ->
|
|||
sourceCode.splice index, 1
|
||||
if removeJs and not opts.join
|
||||
jsPath = outputPath source, base
|
||||
fs.exists jsPath, (itExists) ->
|
||||
if itExists
|
||||
fs.unlink jsPath, (err) ->
|
||||
throw err if err and err.code isnt 'ENOENT'
|
||||
timeLog "removed #{source}"
|
||||
try
|
||||
fs.unlinkSync jsPath
|
||||
catch err
|
||||
throw err unless err.code is 'ENOENT'
|
||||
timeLog "removed #{source}"
|
||||
|
||||
# Get the corresponding output JavaScript path for a source file.
|
||||
outputPath = (source, base, extension=".js") ->
|
||||
|
|
Loading…
Reference in a new issue