From d3e4990a5f24336104ad1ecc02376153c44286f1 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sat, 22 Oct 2016 23:44:46 +0200 Subject: [PATCH] Use forward slashes for all paths in source maps, fix #441 --- lib/output.ts | 6 +++--- lib/utils.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/output.ts b/lib/output.ts index 7802a736..563c886e 100644 --- a/lib/output.ts +++ b/lib/output.ts @@ -58,7 +58,7 @@ export class Output { // gulp-sourcemaps docs: // paths in the generated source map (`file` and `sources`) are relative to `file.base` (e.g. use `file.relative`). - map.file = output.relative; + map.file = utils.forwardSlashes(output.relative); map.sources = map.sources.map(relativeToOutput); delete map.sourceRoot; @@ -93,8 +93,8 @@ export class Output { return generator.toString(); function relativeToOutput(fileName: string) { - const absolute = path.resolve(directory, fileName.replace(/\\/g, '/')); - return path.relative(output.base, absolute); + const absolute = path.resolve(directory, fileName); + return utils.forwardSlashes(path.relative(output.base, absolute)); } } diff --git a/lib/utils.ts b/lib/utils.ts index f7f44ae4..24c62f3d 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -8,6 +8,10 @@ export interface Map { [key: string]: T; } +export function forwardSlashes(fileName: string) { + return fileName.replace(/\\/g, '/') +} + export function normalizePath(pathString: string) { return path.normalize(pathString).toLowerCase(); }