Skip to content

Commit

Permalink
chore(deps): update glob and remove @types/glob (#262)
Browse files Browse the repository at this point in the history
- the glob 9+ use promise instead of callback
- the glob 9+ supports typescript, there is no need to install typedefinition dependencies
  • Loading branch information
yoshinorin authored Mar 20, 2024
1 parent bc400a2 commit 1305af5
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 59 deletions.
3 changes: 1 addition & 2 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
"test": "cd .. && tsc && cd sample && tsc && node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/mocha": "^8.2.0",
"@types/node": "^18",
"@types/vscode": "^1.52.0",
"glob": "^7.1.6",
"glob": "^10.3.10",
"mocha": "^8.2.1",
"typescript": "^4.1.3"
},
Expand Down
38 changes: 19 additions & 19 deletions sample/src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import { glob } from 'glob';

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

glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return cb(err);
}

// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
glob('**/**.test.js', { cwd: testsRoot })
.then((files) => {
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run(failures => {
cb(null, failures);
});
} catch (err) {
console.error(err);
cb(err);
}
});
try {
// Run the mocha test
mocha.run((failures) => {
cb(null, failures);
});
} catch (err) {
console.error(err);
cb(err);
}
})
.catch((err) => {
return cb(err);
});
}
36 changes: 18 additions & 18 deletions sample/src/test/suite2/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import { glob } from 'glob';

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

glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return cb(err);
}

// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
glob('**/**.test.js', { cwd: testsRoot })
.then((files) => {
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run(failures => {
cb(null, failures);
});
} catch (err) {
cb(err);
}
});
try {
// Run the mocha test
mocha.run((failures) => {
cb(null, failures);
});
} catch (err) {
cb(err);
}
})
.catch((err) => {
return cb(err);
});
}
Loading

0 comments on commit 1305af5

Please sign in to comment.