Skip to content

Commit

Permalink
Use forward slashes for all paths in source maps, fix #441
Browse files Browse the repository at this point in the history
  • Loading branch information
ivogabe committed Oct 22, 2016
1 parent b931677 commit d3e4990
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export interface Map<T> {
[key: string]: T;
}

export function forwardSlashes(fileName: string) {
return fileName.replace(/\\/g, '/')
}

export function normalizePath(pathString: string) {
return path.normalize(pathString).toLowerCase();
}
Expand Down

0 comments on commit d3e4990

Please sign in to comment.