mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fixes #3267 -- Remove source maps of deleted source files
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user