Skip to content

Commit 1305af5

Browse files
authored
chore(deps): update glob and remove @types/glob (#262)
- the glob 9+ use promise instead of callback - the glob 9+ supports typescript, there is no need to install typedefinition dependencies
1 parent bc400a2 commit 1305af5

File tree

4 files changed

+249
-59
lines changed

4 files changed

+249
-59
lines changed

sample/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
"test": "cd .. && tsc && cd sample && tsc && node ./out/test/runTest.js"
2929
},
3030
"devDependencies": {
31-
"@types/glob": "^7.1.3",
3231
"@types/mocha": "^8.2.0",
3332
"@types/node": "^18",
3433
"@types/vscode": "^1.52.0",
35-
"glob": "^7.1.6",
34+
"glob": "^10.3.10",
3635
"mocha": "^8.2.1",
3736
"typescript": "^4.1.3"
3837
},

sample/src/test/suite/index.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import * as path from 'path';
22
import * as Mocha from 'mocha';
3-
import * as glob from 'glob';
3+
import { glob } from 'glob';
44

55
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
66
// Create the mocha test
77
const mocha = new Mocha({
8-
ui: 'tdd'
8+
ui: 'tdd',
99
});
1010

11-
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
12-
if (err) {
13-
return cb(err);
14-
}
15-
16-
// Add files to the test suite
17-
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
11+
glob('**/**.test.js', { cwd: testsRoot })
12+
.then((files) => {
13+
// Add files to the test suite
14+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
1815

19-
try {
20-
// Run the mocha test
21-
mocha.run(failures => {
22-
cb(null, failures);
23-
});
24-
} catch (err) {
25-
console.error(err);
26-
cb(err);
27-
}
28-
});
16+
try {
17+
// Run the mocha test
18+
mocha.run((failures) => {
19+
cb(null, failures);
20+
});
21+
} catch (err) {
22+
console.error(err);
23+
cb(err);
24+
}
25+
})
26+
.catch((err) => {
27+
return cb(err);
28+
});
2929
}

sample/src/test/suite2/index.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import * as path from 'path';
22
import * as Mocha from 'mocha';
3-
import * as glob from 'glob';
3+
import { glob } from 'glob';
44

55
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
66
// Create the mocha test
77
const mocha = new Mocha({
8-
ui: 'tdd'
8+
ui: 'tdd',
99
});
1010

11-
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
12-
if (err) {
13-
return cb(err);
14-
}
15-
16-
// Add files to the test suite
17-
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
11+
glob('**/**.test.js', { cwd: testsRoot })
12+
.then((files) => {
13+
// Add files to the test suite
14+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
1815

19-
try {
20-
// Run the mocha test
21-
mocha.run(failures => {
22-
cb(null, failures);
23-
});
24-
} catch (err) {
25-
cb(err);
26-
}
27-
});
16+
try {
17+
// Run the mocha test
18+
mocha.run((failures) => {
19+
cb(null, failures);
20+
});
21+
} catch (err) {
22+
cb(err);
23+
}
24+
})
25+
.catch((err) => {
26+
return cb(err);
27+
});
2828
}

0 commit comments

Comments
 (0)