diff --git a/lib/6to5/transformation/file.js b/lib/6to5/transformation/file.js index b41b853319..2eccb48b3a 100644 --- a/lib/6to5/transformation/file.js +++ b/lib/6to5/transformation/file.js @@ -123,7 +123,10 @@ File.prototype.normalizeOptions = function (opts) { }); // normalize windows path separators to unix - opts.filename = opts.filename.replace(/\\/g, "/"); + opts.filename = util.normalisePathSeparator(opts.filename); + if (opts.sourceRoot) { + opts.sourceRoot = util.normalisePathSeparator(opts.sourceRoot); + } opts.basename = path.basename(opts.filename, path.extname(opts.filename)); diff --git a/lib/6to5/util.js b/lib/6to5/util.js index 501315617f..5afe1e97e1 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -30,6 +30,10 @@ exports.canCompile = function (filename, altExts) { exports.canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"]; +exports.normalisePathSeparator = function (filename) { + return filename.replace(/\\/g, "/"); +}; + exports.isInteger = function (i) { return isNumber(i) && i % 1 === 0; };