Skip to content

Commit 007ff4d

Browse files
Hristo HristovHristo Hristov
authored andcommitted
fix(cli): update glob to 11.0.0 and fix tests
1 parent 2ad4b12 commit 007ff4d

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@inquirer/prompts": "~5.4.0",
1616
"chalk": "^2.3.2",
17-
"glob": "^7.1.2",
17+
"glob": "^11.0.0",
1818
"through2": "^2.0.3",
1919
"typescript": "~5.5.4"
2020
},

packages/core/util/FileSystem.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class FsFileSystem implements IFileSystem {
3030
}
3131

3232
public glob(dirPath: string, pattern: string): string[] {
33-
return glob.sync(path.join(dirPath, pattern), { nodir: true });
33+
return glob.sync(path.join(dirPath, pattern), { nodir: true })
34+
.map(filePath => filePath.replace(/\\/g, "/"));
3435
}
3536
}

packages/core/util/Util.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export class Util {
7979
}
8080

8181
return new Promise((resolve, reject) => {
82-
const filePaths: string[] = glob.sync(sourcePath + "/**/*", { nodir: true });
82+
const filePaths: string[] = glob.sync(sourcePath + "/**/*", { nodir: true })
83+
.map(filePath => filePath.replace(/\\/g, "/"));
8384
let fileCount = filePaths.length;
8485
// if no files should be created, resolve
8586
if (fileCount === 0) {
@@ -608,9 +609,11 @@ export class Util {
608609
sourcePath = sourcePath.replace(/\\/g, "/");
609610
destinationPath = destinationPath.replace(/\\/g, "/");
610611

611-
let paths: string[] = glob.sync(sourcePath + "/**/*", { nodir: true });
612+
let paths: string[] = glob.sync(sourcePath + "/**/*", { nodir: true })
613+
.map(filePath => filePath.replace(/\\/g, "/"));
612614
// TODO: D.P Temporary ignoring asset files
613-
const ignorePaths: string[] = glob.sync(sourcePath + "/**/+(assets|data)/**/*", { nodir: true });
615+
const ignorePaths: string[] = glob.sync(sourcePath + "/**/+(assets|data)/**/*", { nodir: true })
616+
.map(filePath => filePath.replace(/\\/g, "/"));
614617
paths = paths.filter(x => ignorePaths.indexOf(x) === -1);
615618

616619
for (let filePath of paths) {

spec/acceptance/add-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe("Add command", () => {
128128
await cli.run(["add", "grid", "Test view"]);
129129

130130
expect(console.error).toHaveBeenCalledWith(
131-
jasmine.stringMatching(/test-view[\\\/]index.html already exists!*/)
131+
jasmine.stringMatching(/test-view[\\\/]style.css already exists!*/)
132132
);
133133
expect(fs.readFileSync("./test-view/index.html").toString()).toEqual("test", "Shouldn't overwrite file contents");
134134

@@ -137,7 +137,7 @@ describe("Add command", () => {
137137
await cli.run(["add", "grid", "test-View"]);
138138

139139
expect(console.error).toHaveBeenCalledWith(
140-
jasmine.stringMatching(/test-view[\\\/]index.html already exists!*/)
140+
jasmine.stringMatching(/test-view[\\\/]style.css already exists!*/)
141141
);
142142
expect(fs.readFileSync("./test-view/index.html").toString()).toEqual("test", "Shouldn't overwrite file contents");
143143

@@ -146,7 +146,7 @@ describe("Add command", () => {
146146
await cli.run(["add", "grid", " Test-view \t "]);
147147

148148
expect(console.error).toHaveBeenCalledWith(
149-
jasmine.stringMatching(/test-view[\\\/]index.html already exists!*/)
149+
jasmine.stringMatching(/test-view[\\\/]style.css already exists!*/)
150150
);
151151
expect(fs.readFileSync("./test-view/index.html").toString()).toEqual("test", "Shouldn't overwrite file contents");
152152

spec/helpers/utils.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import * as glob from "glob";
66
* @param folderPath Folder path
77
*/
88
export function deleteAll(folderPath: string) {
9-
const files: string[] = glob.sync(folderPath + "/**/*", { dot: true, nodir: true });
9+
const files: string[] = glob.sync(folderPath + "/**/*", { dot: true, nodir: true })
10+
.map(filePath => filePath.replace(/\\/g, "/"));
1011
files.forEach(x => fs.unlinkSync(x));
11-
const folders: string[] = glob.sync(folderPath + "/**/*", { dot: true });
12+
const folders: string[] = glob.sync(folderPath + "/**/*", { dot: true })
13+
.map(filePath => filePath.replace(/\\/g, "/"));
1214
folders.reverse().forEach(x => fs.rmdirSync(x));
1315
}
1416

@@ -25,8 +27,10 @@ export function filesDiff(
2527
transform1?: (val: string) => string,
2628
transform2?: (val: string) => string
2729
): string[] {
28-
let files1: string[] = glob.sync("**/*", {cwd: folderPath1, dot: true, nodir: true });
29-
let files2: string[] = glob.sync("**/*", {cwd: folderPath1, dot: true, nodir: true });
30+
let files1: string[] = glob.sync("**/*", {cwd: folderPath1, dot: true, nodir: true })
31+
.map(filePath => filePath.replace(/\\/g, "/"));
32+
let files2: string[] = glob.sync("**/*", {cwd: folderPath1, dot: true, nodir: true })
33+
.map(filePath => filePath.replace(/\\/g, "/"));
3034
if (transform1) {
3135
files1 = files1.map(transform1);
3236
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,7 @@ glob@^11.0.0:
35213521
package-json-from-dist "^1.0.0"
35223522
path-scurry "^2.0.0"
35233523

3524-
glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7:
3524+
glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7:
35253525
version "7.2.3"
35263526
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
35273527
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==

0 commit comments

Comments
 (0)