Skip to content

Commit

Permalink
chore: fix minimatch import
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Dec 21, 2024
1 parent f71f051 commit 5f774e3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
42 changes: 37 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^8.0.3",
"minimatch": "^9.0.5",
"minimatch": "^10.0.1",
"typescript": "^5.4.3"
},
"dependencies": {
Expand Down
11 changes: 7 additions & 4 deletions tests/mock/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import fs from 'fs';
import glob from 'glob';
import path from 'path';
import { Disposable, EventEmitter, Event } from '../../src/upstream/events';
// @ts-ignore
import { minimatch } from 'minimatch';
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
import which from 'which';
Expand Down Expand Up @@ -163,7 +162,7 @@ export class WorkspaceFolder {
await fs.promises.writeFile(fsPath, content);
if (!isNewWorkspace) {
for (const watcher of this.vscode.fsWatchers) {
if (minimatch(fsPath, watcher.glob))
if (matchGlob(fsPath, watcher.glob))
watcher.didCreate.fire(Uri.file(fsPath));
}
}
Expand All @@ -173,7 +172,7 @@ export class WorkspaceFolder {
const fsPath = path.join(this.uri.fsPath, file);
await fs.promises.unlink(fsPath);
for (const watcher of this.vscode.fsWatchers) {
if (minimatch(fsPath, watcher.glob))
if (matchGlob(fsPath, watcher.glob))
watcher.didDelete.fire(Uri.file(fsPath));
}
}
Expand All @@ -184,7 +183,7 @@ export class WorkspaceFolder {
const fsPath = path.join(this.uri.fsPath, file);
await fs.promises.writeFile(fsPath, content);
for (const watcher of this.vscode.fsWatchers) {
if (minimatch(fsPath, watcher.glob))
if (matchGlob(fsPath, watcher.glob))
watcher.didChange.fire(Uri.file(fsPath));
}
}
Expand Down Expand Up @@ -1346,3 +1345,7 @@ const ansiRegex = new RegExp('[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(
export function stripAnsi(str: string): string {
return str.replace(ansiRegex, '');
}

function matchGlob(file: string, pattern: string): boolean {
return minimatch(file.replaceAll(path.sep, '/'), pattern.replaceAll(path.sep, '/'));
}

0 comments on commit 5f774e3

Please sign in to comment.