Skip to content

Commit

Permalink
chore: simplify isGlob helper
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Nov 15, 2024
1 parent b6745f0 commit f2ab53c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@rslib/core": "0.0.18",
"@types/connect": "3.4.38",
"@types/fs-extra": "^11.0.4",
"@types/is-glob": "^4.0.4",
"@types/node": "^22.9.0",
"@types/on-finished": "2.3.4",
"@types/webpack-bundle-analyzer": "4.7.0",
Expand All @@ -77,7 +76,6 @@
"fs-extra": "^11.2.0",
"html-rspack-plugin": "6.0.2",
"http-proxy-middleware": "^2.0.6",
"is-glob": "^4.0.3",
"jiti": "^1.21.6",
"launch-editor-middleware": "^2.9.1",
"mrmime": "^2.0.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/server/watchFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isGlob from 'is-glob';
import type { FSWatcher } from '../../compiled/chokidar/index.js';
import { normalizePublicDirs } from '../config';
import { castArray } from '../helpers';
Expand Down Expand Up @@ -116,6 +115,13 @@ function prepareWatchOptions(
};
}

const GLOB_REGEX = /[*?{}[\]()!@+|]/;
/**
* A simple glob pattern checker.
* This can help us to avoid unnecessary tinyglobby import and call.
*/
const isGlob = (str: string): boolean => GLOB_REGEX.test(str);

export async function createChokidar(
pathOrGlobs: string[],
root: string,
Expand Down
11 changes: 0 additions & 11 deletions pnpm-lock.yaml

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

0 comments on commit f2ab53c

Please sign in to comment.