Skip to content

Commit d35cb7f

Browse files
GudineWestbrook
andauthored
Backslash-related fixes for Windows (#151)
* fix: makes glob patterns accept backslashes as separators again * fix: normalizes tree view path separator on Windows * style: fixes lint error --------- Co-authored-by: Westbrook Johnson <[email protected]>
1 parent f84b958 commit d35cb7f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/core.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ export function filesToTree(allFiles, level = 0) {
277277
*/
278278
export async function writeFilesToDisk() {
279279
const treeFiles = [];
280-
const root = process.cwd();
280+
const root = process.cwd().replace(/\\/g, '/');
281+
282+
virtualFiles.forEach((vFile, i) => {
283+
virtualFiles[i].path = vFile.path.replace(/\\/g, '/');
284+
});
285+
281286
virtualFiles.sort((a, b) => {
282287
const pathA = a.path.toLowerCase();
283288
const pathB = b.path.toLowerCase();
@@ -369,7 +374,7 @@ export function copyTemplate(fromPath, toPath, data, ejsOptions = {}) {
369374
*/
370375
export function copyTemplates(fromGlob, toDir = process.cwd(), data = {}, ejsOptions = {}) {
371376
return new Promise(resolve => {
372-
glob(fromGlob, { dot: true }, (er, files) => {
377+
glob(fromGlob, { dot: true, windowsPathsNoEscape: true }, (er, files) => {
373378
const copiedFiles = [];
374379
files.forEach(filePath => {
375380
if (!fs.lstatSync(filePath).isDirectory()) {

0 commit comments

Comments
 (0)