1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fixes #3267 -- Remove source maps of deleted source files

This commit is contained in:
Marc Häfner 2013-12-01 12:03:22 +01:00
parent 54633aee3f
commit 73af30b5d8
2 changed files with 24 additions and 16 deletions

View file

@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.3
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, _ref,
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
fs = require('fs');
@ -354,24 +354,29 @@
};
removeSource = function(source, base) {
var err, index, jsPath;
var index;
index = sources.indexOf(source);
sources.splice(index, 1);
sourceCode.splice(index, 1);
if (!opts.join) {
jsPath = outputPath(source, base);
try {
fs.unlinkSync(jsPath);
} catch (_error) {
err = _error;
if (err.code !== 'ENOENT') {
throw err;
}
}
silentUnlink(outputPath(source, base));
silentUnlink(outputPath(source, base, '.map'));
return timeLog("removed " + source);
}
};
silentUnlink = function(path) {
var err;
try {
return fs.unlinkSync(path);
} catch (_error) {
err = _error;
if (err.code !== 'ENOENT') {
throw err;
}
}
};
outputPath = function(source, base, extension) {
var basename, dir, srcDir;
if (extension == null) {

View file

@ -258,13 +258,16 @@ removeSource = (source, base) ->
sources.splice index, 1
sourceCode.splice index, 1
unless opts.join
jsPath = outputPath source, base
try
fs.unlinkSync jsPath
catch err
throw err unless err.code is 'ENOENT'
silentUnlink outputPath source, base
silentUnlink outputPath source, base, '.map'
timeLog "removed #{source}"
silentUnlink = (path) ->
try
fs.unlinkSync path
catch err
throw err unless err.code is 'ENOENT'
# Get the corresponding output JavaScript path for a source file.
outputPath = (source, base, extension=".js") ->
basename = helpers.baseFileName source, yes, useWinPathSep