Skip to content

Commit

Permalink
Normalize backslash on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 25, 2019
1 parent a0eab48 commit 2fe0ba5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/template-common.js
Expand Up @@ -20,11 +20,12 @@ const hashRegexp = /Hash: [a-f0-9]+/g;

exports.replaceBase = (template) => {

let cwd = process.cwd();
const cwd = process.cwd();
let webpack = path.join(__dirname, "..");
let webpackParent = path.join(__dirname, "..", "..");
cwd = lessStrict(cwd.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
cwd = new RegExp(cwd, "g");
const cwdRegExpStr = lessStrict(cwd.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
const cwdRegExp = new RegExp(cwdRegExpStr, "g");
const cwdSlashRegExp = new RegExp(cwdRegExpStr + "[\\/\\\\]", "g");
webpack = lessStrict(webpack.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
webpack = new RegExp(webpack, "g");
webpackParent = lessStrict(webpackParent.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
Expand All @@ -33,7 +34,8 @@ exports.replaceBase = (template) => {
return template
.replace(/\r\n/g, "\n")
.replace(/\r/g, "\n")
.replace(cwd, ".")
.replace(cwdSlashRegExp, "./")
.replace(cwdRegExp, ".")
.replace(webpack, "(webpack)")
.replace(webpackParent, "(webpack)/~")
.replace(timeRegexp, "")
Expand Down

0 comments on commit 2fe0ba5

Please sign in to comment.