Prevent writing the same file several times (fixes #3753)

This commit is contained in:
Alberto Torres Ruiz 2015-02-12 20:15:53 +01:00
parent dc8a2b17d0
commit 6bc3157793
2 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.9.0
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
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');
@ -49,6 +49,8 @@
optionParser = null;
jsToSources = {};
exports.run = function() {
var i, len, literals, ref1, replCliOpts, results, source;
parseOptions();
@ -466,6 +468,13 @@
}
sourceMapPath = outputPath(sourcePath, base, ".js.map");
jsDir = path.dirname(jsPath);
if (jsPath in jsToSources) {
printLine("Error: The two following source files have the same output file:");
printLine(" " + jsToSources[jsPath]);
printLine(" " + sourcePath);
process.exit(1);
}
jsToSources[jsPath] = sourcePath;
compile = function() {
if (opts.compile) {
if (js.length <= 0) {

View File

@ -58,6 +58,7 @@ sourceCode = []
notSources = {}
watchedDirs = {}
optionParser = null
jsToSources = {}
# Run `coffee` by parsing passed options and determining what action to take.
# Many flags cause us to divert before compiling anything. Flags passed after
@ -352,6 +353,12 @@ mkdirp = (dir, fn) ->
writeJs = (base, sourcePath, js, jsPath, generatedSourceMap = null) ->
sourceMapPath = outputPath sourcePath, base, ".js.map"
jsDir = path.dirname jsPath
if jsPath of jsToSources
printLine "Error: The two following source files have the same output file:"
printLine " " + jsToSources[jsPath]
printLine " " + sourcePath
process.exit 1
jsToSources[jsPath] = sourcePath
compile = ->
if opts.compile
js = ' ' if js.length <= 0