fix path handling on Windows
This commit is contained in:
parent
56413ba3b4
commit
f217a10721
|
@ -387,7 +387,7 @@
|
|||
if (extension == null) {
|
||||
extension = ".js";
|
||||
}
|
||||
basename = helpers.baseFileName(source, true);
|
||||
basename = helpers.baseFileName(source, true, path.sep);
|
||||
srcDir = path.dirname(source);
|
||||
baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
|
||||
dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
|
||||
|
@ -407,7 +407,7 @@
|
|||
js = ' ';
|
||||
}
|
||||
if (generatedSourceMap) {
|
||||
js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath)) + "\n*/\n";
|
||||
js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, path.sep)) + "\n*/\n";
|
||||
}
|
||||
fs.writeFile(jsPath, js, function(err) {
|
||||
if (err) {
|
||||
|
@ -503,13 +503,13 @@
|
|||
jsPath: jsPath,
|
||||
sourceRoot: path.relative(jsDir, cwd),
|
||||
sourceFiles: [path.relative(cwd, filename)],
|
||||
generatedFile: helpers.baseFileName(jsPath)
|
||||
generatedFile: helpers.baseFileName(jsPath, false, path.sep)
|
||||
});
|
||||
} else {
|
||||
answer = helpers.merge(answer, {
|
||||
sourceRoot: "",
|
||||
sourceFiles: [helpers.baseFileName(filename)],
|
||||
generatedFile: helpers.baseFileName(filename, true) + ".js"
|
||||
sourceFiles: [helpers.baseFileName(filename, false, path.sep)],
|
||||
generatedFile: helpers.baseFileName(filename, true, path.sep) + ".js"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,12 +153,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
exports.baseFileName = function(file, stripExt) {
|
||||
exports.baseFileName = function(file, stripExt, pathSep) {
|
||||
var parts;
|
||||
if (stripExt == null) {
|
||||
stripExt = false;
|
||||
}
|
||||
parts = file.split('/');
|
||||
if (pathSep == null) {
|
||||
pathSep = '/';
|
||||
}
|
||||
parts = file.split(pathSep);
|
||||
file = parts[parts.length - 1];
|
||||
if (!stripExt) {
|
||||
return file;
|
||||
|
|
|
@ -256,7 +256,7 @@ removeSource = (source, base, removeJs) ->
|
|||
|
||||
# Get the corresponding output JavaScript path for a source file.
|
||||
outputPath = (source, base, extension=".js") ->
|
||||
basename = helpers.baseFileName source, yes
|
||||
basename = helpers.baseFileName source, yes, path.sep
|
||||
srcDir = path.dirname source
|
||||
baseDir = if base is '.' then srcDir else srcDir.substring base.length
|
||||
dir = if opts.output then path.join opts.output, baseDir else srcDir
|
||||
|
@ -274,7 +274,7 @@ writeJs = (base, sourcePath, js, jsPath, generatedSourceMap = null) ->
|
|||
compile = ->
|
||||
if opts.compile
|
||||
js = ' ' if js.length <= 0
|
||||
if generatedSourceMap then js = "#{js}\n/*\n//@ sourceMappingURL=#{helpers.baseFileName sourceMapPath}\n*/\n"
|
||||
if generatedSourceMap then js = "#{js}\n/*\n//@ sourceMappingURL=#{helpers.baseFileName sourceMapPath, no, path.sep}\n*/\n"
|
||||
fs.writeFile jsPath, js, (err) ->
|
||||
if err
|
||||
printLine err.message
|
||||
|
@ -343,13 +343,13 @@ compileOptions = (filename, base) ->
|
|||
jsPath
|
||||
sourceRoot: path.relative jsDir, cwd
|
||||
sourceFiles: [path.relative cwd, filename]
|
||||
generatedFile: helpers.baseFileName(jsPath)
|
||||
generatedFile: helpers.baseFileName(jsPath, no, path.sep)
|
||||
}
|
||||
else
|
||||
answer = helpers.merge answer,
|
||||
sourceRoot: ""
|
||||
sourceFiles: [helpers.baseFileName filename]
|
||||
generatedFile: helpers.baseFileName(filename, yes) + ".js"
|
||||
sourceFiles: [helpers.baseFileName filename, no, path.sep]
|
||||
generatedFile: helpers.baseFileName(filename, yes, path.sep) + ".js"
|
||||
answer
|
||||
|
||||
# Start up a new Node.js instance with the arguments in `--nodejs` passed to
|
||||
|
|
|
@ -115,8 +115,8 @@ exports.locationDataToString = (obj) ->
|
|||
"No location data"
|
||||
|
||||
# A `.coffee.md` compatible version of `basename`, that returns the file sans-extension.
|
||||
exports.baseFileName = (file, stripExt = no) ->
|
||||
parts = file.split('/')
|
||||
exports.baseFileName = (file, stripExt = no, pathSep = '/') ->
|
||||
parts = file.split(pathSep)
|
||||
file = parts[parts.length - 1]
|
||||
return file unless stripExt
|
||||
parts = file.split('.')
|
||||
|
|
Loading…
Reference in New Issue