Skip to content

Commit

Permalink
Fix build on Windows (#381)
Browse files Browse the repository at this point in the history
Use `path.dirName` instead of a `file.replace` on regex'd replaced string
  • Loading branch information
qcz authored and JoelMarcey committed Jan 8, 2018
1 parent 65085b1 commit 654916a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/server/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function execute() {

// create the folder path for a file if it does not exist, then write the file
function writeFileAndCreateFolder(file, content) {
mkdirp.sync(file.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(file));

fs.writeFileSync(file, content);
}
Expand Down Expand Up @@ -346,10 +346,10 @@ function execute() {
codeColor
);

mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(targetFile));
fs.writeFileSync(targetFile, cssContent);
} else if (!fs.lstatSync(file).isDirectory()) {
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(targetFile));
fs.copySync(file, targetFile);
}
});
Expand All @@ -372,7 +372,7 @@ function execute() {
} else if (!fs.lstatSync(file).isDirectory()) {
let parts = file.split('/static/');
let targetFile = join(buildDir, parts[1]);
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(targetFile));
fs.copySync(file, targetFile);
}
});
Expand All @@ -390,7 +390,7 @@ function execute() {
path.basename(file),
'temp' + path.basename(file)
);
mkdirp.sync(tempFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(tempFile));
fs.copySync(file, tempFile);

const ReactComp = require(tempFile);
Expand Down Expand Up @@ -465,7 +465,7 @@ function execute() {
// copy other non .js files
let parts = file.split('pages');
let targetFile = join(buildDir, parts[1]);
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(targetFile));
fs.copySync(file, targetFile);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ function execute(port) {
path.basename(file),
'temp' + path.basename(file)
);
mkdirp.sync(tempFile.replace(new RegExp('/[^/]*$'), ''));
mkdirp.sync(path.dirname(tempFile));
fs.copySync(userFile, tempFile);

// render into a string
Expand Down

0 comments on commit 654916a

Please sign in to comment.