Skip to content

Commit

Permalink
Backslash-related fixes for Windows (#151)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Gudine and Westbrook authored Jul 9, 2024
1 parent f84b958 commit d35cb7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ export function filesToTree(allFiles, level = 0) {
*/
export async function writeFilesToDisk() {
const treeFiles = [];
const root = process.cwd();
const root = process.cwd().replace(/\\/g, '/');

virtualFiles.forEach((vFile, i) => {
virtualFiles[i].path = vFile.path.replace(/\\/g, '/');
});

virtualFiles.sort((a, b) => {
const pathA = a.path.toLowerCase();
const pathB = b.path.toLowerCase();
Expand Down Expand Up @@ -369,7 +374,7 @@ export function copyTemplate(fromPath, toPath, data, ejsOptions = {}) {
*/
export function copyTemplates(fromGlob, toDir = process.cwd(), data = {}, ejsOptions = {}) {
return new Promise(resolve => {
glob(fromGlob, { dot: true }, (er, files) => {
glob(fromGlob, { dot: true, windowsPathsNoEscape: true }, (er, files) => {
const copiedFiles = [];
files.forEach(filePath => {
if (!fs.lstatSync(filePath).isDirectory()) {
Expand Down

0 comments on commit d35cb7f

Please sign in to comment.