Skip to content

Commit 05e0d2c

Browse files
authored
Merge pull request #4601 from github/josefs/replace-packages-with-node-22-built-ins
Replace `glob` dependency with `glob` from `fs/promises`
2 parents 18666f4 + ef13e95 commit 05e0d2c

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎extensions/ql-vscode/package-lock.json‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎extensions/ql-vscode/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,6 @@
21552155
"eslint-plugin-react": "^7.37.5",
21562156
"eslint-plugin-react-hooks": "^7.1.1",
21572157
"eslint-plugin-storybook": "^10.6.1",
2158-
"glob": "^13.0.6",
21592158
"gulp": "^5.0.1",
21602159
"gulp-esbuild": "^0.14.1",
21612160
"gulp-typescript": "^5.0.1",

‎extensions/ql-vscode/src/databases/local-databases/database-resolver.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
DatabaseContentsWithDbScheme,
77
} from "./database-contents";
88
import { DatabaseKind } from "./database-contents";
9-
import { glob } from "glob";
9+
import { glob } from "fs/promises";
1010
import { encodeArchiveBasePath } from "../../common/vscode/archive-filesystem-provider";
1111
import {
1212
showAndLogInformationMessage,
@@ -87,17 +87,22 @@ async function findDataset(parentDirectory: string): Promise<Uri> {
8787
/*
8888
* Look directly in the root
8989
*/
90-
let dbRelativePaths = await glob("db-*/", {
90+
const dbRelativePaths: string[] = [];
91+
for await (const path of glob("db-*/", {
9192
cwd: parentDirectory,
92-
});
93+
})) {
94+
dbRelativePaths.push(path);
95+
}
9396

9497
if (dbRelativePaths.length === 0) {
9598
/*
9699
* Check If they are in the old location
97100
*/
98-
dbRelativePaths = await glob("working/db-*/", {
101+
for await (const path of glob("working/db-*/", {
99102
cwd: parentDirectory,
100-
});
103+
})) {
104+
dbRelativePaths.push(path);
105+
}
101106
}
102107
if (dbRelativePaths.length === 0) {
103108
throw new InvalidDatabaseError(
@@ -118,7 +123,11 @@ async function findDataset(parentDirectory: string): Promise<Uri> {
118123

119124
/** Gets the relative paths of all `.dbscheme` files in the given directory. */
120125
async function getDbSchemeFiles(dbDirectory: string): Promise<string[]> {
121-
return await glob("*.dbscheme", { cwd: dbDirectory });
126+
const dbSchemeFiles: string[] = [];
127+
for await (const file of glob("*.dbscheme", { cwd: dbDirectory })) {
128+
dbSchemeFiles.push(file);
129+
}
130+
return dbSchemeFiles;
122131
}
123132

124133
// exported for testing

‎extensions/ql-vscode/src/databases/local-databases/db-contents-heuristics.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { pathExists } from "fs-extra";
22
import { basename, join } from "path";
3-
import { glob } from "glob";
3+
import { glob } from "fs/promises";
44

55
/**
66
* The following functions al heuristically determine metadata about databases.
@@ -19,10 +19,10 @@ export async function isLikelyDatabaseRoot(maybeRoot: string) {
1919
pathExists(join(maybeRoot, "codeql-database.yml")),
2020

2121
// they *must* have a db-{language} folder
22-
glob("db-*/", { cwd: maybeRoot }),
22+
glob("db-*/", { cwd: maybeRoot }).next(),
2323
]);
2424

25-
return (a || b) && c.length > 0;
25+
return (a || b) && !c.done;
2626
}
2727

2828
/**

‎extensions/ql-vscode/src/databases/qlpack.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { window } from "vscode";
2-
import { glob } from "glob";
2+
import { glob } from "fs/promises";
33
import { basename } from "path";
44
import { load } from "js-yaml";
55
import { readFile } from "fs-extra";
@@ -108,9 +108,12 @@ export async function getQlPackForDbscheme(
108108
export async function getPrimaryDbscheme(
109109
datasetFolder: string,
110110
): Promise<string> {
111-
const dbschemes = await glob("*.dbscheme", {
111+
const dbschemes: string[] = [];
112+
for await (const file of glob("*.dbscheme", {
112113
cwd: datasetFolder,
113-
});
114+
})) {
115+
dbschemes.push(file);
116+
}
114117

115118
if (dbschemes.length < 1) {
116119
throw new Error(

0 commit comments

Comments
 (0)