Skip to content

Commit 864f275

Browse files
committed
Update the glob usage to match the new api.
1 parent d0d0a46 commit 864f275

File tree

4 files changed

+21
-54
lines changed

4 files changed

+21
-54
lines changed

src/telemetryGenerator.node.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,15 +771,7 @@ function generateTelemetryGdpr(output: TelemetryEntry[]) {
771771
}
772772

773773
async function generateTelemetryOutput() {
774-
const files = await new Promise<string[]>((resolve, reject) => {
775-
glob(path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src/**/*.ts'), (ex, res) => {
776-
if (ex) {
777-
reject(ex);
778-
} else {
779-
resolve(res);
780-
}
781-
});
782-
});
774+
const files = await glob(path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src/**/*.ts'));
783775
// Print out the source tree
784776
return generateDocumentation(files);
785777
}

src/test/extension.serviceRegistry.vscode.test.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,8 @@ async function getInjectableClasses(fileNames: string[], options: ts.CompilerOpt
114114
}
115115

116116
async function getSourceFiles() {
117-
const files = await new Promise<string[]>((resolve, reject) => {
118-
const globPattern = path.join(__dirname, '..', '..', 'src', '**', '*.ts').replace(/\\/g, '/');
119-
glob(globPattern, (ex, res) => {
120-
if (ex) {
121-
reject(ex);
122-
} else {
123-
resolve(res);
124-
}
125-
});
126-
});
117+
const globPattern = path.join(__dirname, '..', '..', 'src', '**', '*.ts').replace(/\\/g, '/');
118+
const files = await glob(globPattern);
127119
return files;
128120
}
129121

src/test/index.node.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,13 @@ export async function run(): Promise<void> {
187187
default:
188188
break;
189189
}
190-
const testFiles = await new Promise<string[]>((resolve, reject) => {
191-
// If we have mulitple patterns, then turn into regex from `a,b,c` to `(a|b|c)`
192-
const pattern = options.testFilesSuffix.includes(',')
193-
? `(${options.testFilesSuffix.split(',').join('|')})`
194-
: options.testFilesSuffix;
195-
glob(
196-
`**/*${pattern}.js`,
197-
{ ignore: ['**/**.unit.test.js'].concat(ignoreGlob), cwd: testsRoot },
198-
(error, files) => {
199-
if (error) {
200-
return reject(error);
201-
}
202-
resolve(files);
203-
}
204-
);
190+
// If we have mulitple patterns, then turn into regex from `a,b,c` to `(a|b|c)`
191+
const pattern = options.testFilesSuffix.includes(',')
192+
? `(${options.testFilesSuffix.split(',').join('|')})`
193+
: options.testFilesSuffix;
194+
const testFiles = await glob(`**/*${pattern}.js`, {
195+
ignore: ['**/**.unit.test.js'].concat(ignoreGlob),
196+
cwd: testsRoot
205197
});
206198

207199
// Setup test files that need to be run.

src/test/testRunner.ts

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,17 @@ export async function run(): Promise<void> {
7171
return promise;
7272
}
7373
// Run the tests.
74+
const files = await glob(`**/**.${testFilesGlob}.js`, { ignore: ['**/**.unit.test.js'], cwd: testsRoot });
75+
files.forEach((file) => mocha.addFile(path.join(testsRoot, file)));
76+
7477
await new Promise<void>((resolve, reject) => {
75-
glob(`**/**.${testFilesGlob}.js`, { ignore: ['**/**.unit.test.js'], cwd: testsRoot }, (error, files) => {
76-
if (error) {
77-
return reject(error);
78-
}
79-
try {
80-
files.forEach((file) => mocha.addFile(path.join(testsRoot, file)));
81-
initializationScript()
82-
.then(() =>
83-
mocha.run((failures) =>
84-
failures > 0 ? reject(new Error(`${failures} total failures`)) : resolve()
85-
)
86-
)
87-
.finally(() => {
88-
stopJupyterServer().catch(noop);
89-
})
90-
.catch(reject);
91-
} catch (error) {
92-
return reject(error);
93-
}
94-
});
78+
initializationScript()
79+
.then(() =>
80+
mocha.run((failures) => (failures > 0 ? reject(new Error(`${failures} total failures`)) : resolve()))
81+
)
82+
.finally(() => {
83+
stopJupyterServer().catch(noop);
84+
})
85+
.catch(reject);
9586
});
9687
}

0 commit comments

Comments
 (0)