@jsenv/filesystem 2.5.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,10 +18,13 @@ console.log(relativeUrl) // "src/file.js"
18
18
  ```js
19
19
  import { listFilesMatching } from "@jsenv/filesystem"
20
20
 
21
- const jsFiles = await listFilesMatching(
22
- "./**/*.js",
23
- new URL("./", import.meta.url),
24
- )
21
+ const jsFiles = await listFilesMatching({
22
+ directoryUrl: new URL("./", import.meta.url),
23
+ patterns: {
24
+ "./**/*.js": true,
25
+ "./**/*.test.js": false,
26
+ },
27
+ })
25
28
  ```
26
29
 
27
30
  ```console
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/filesystem",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "Collection of functions to interact with filesystem in Node.js",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -13,57 +13,45 @@
13
13
  "url": "https://github.com/jsenv/filesystem"
14
14
  },
15
15
  "engines": {
16
- "node": ">=14.17.0"
16
+ "node": ">=16.13.0"
17
17
  },
18
18
  "publishConfig": {
19
- "access": "public",
20
- "registry": "https://registry.npmjs.org"
19
+ "access": "public"
21
20
  },
22
21
  "type": "module",
23
22
  "exports": {
24
23
  ".": {
25
- "import": "./main.js",
26
- "require": "./dist/commonjs/jsenv_filesystem.cjs"
24
+ "import": "./main.js"
27
25
  },
28
26
  "./*": "./*"
29
27
  },
30
28
  "files": [
31
- "/dist/",
32
29
  "/src/",
33
30
  "/main.js"
34
31
  ],
35
32
  "scripts": {
36
- "eslint-check": "node ./node_modules/eslint/bin/eslint.js .",
37
- "generate-importmap": "node ./script/importmap/generate_importmap.mjs",
38
- "measure-performances": "node ./script/performance/generate_performance_report.mjs --local",
39
- "dist": "npm run build",
40
- "build": "node --experimental-import-meta-resolve ./script/build/build.mjs",
33
+ "eslint": "node ./node_modules/eslint/bin/eslint.js .",
34
+ "importmap": "node ./script/importmap/importmap.mjs",
35
+ "performance": "node --expose-gc ./script/performance/performance.mjs --log",
41
36
  "test": "node ./script/test/test.mjs",
42
37
  "test-with-coverage": "npm run test -- --coverage",
43
- "prettier-format": "node ./script/prettier/prettier_format.mjs",
44
- "prettier-format-stage": "npm run prettier-format -- --staged",
45
- "prettier-check": "npm run prettier-format -- --dry-run",
46
- "prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
47
- "postpublish": "node ./script/publish/restore_postinstall.mjs"
38
+ "prettier": "prettier --write ."
48
39
  },
49
40
  "dependencies": {
50
41
  "@jsenv/abort": "3.1.1",
51
42
  "@jsenv/url-meta": "6.0.1"
52
43
  },
53
44
  "devDependencies": {
54
- "@babel/core": "7.16.0",
55
- "@babel/eslint-parser": "7.16.0",
56
- "@jsenv/assert": "2.3.2",
57
- "@jsenv/core": "23.2.2",
58
- "@jsenv/eslint-config": "16.0.8",
45
+ "@jsenv/assert": "2.4.0",
46
+ "@jsenv/core": "24.5.8",
47
+ "@jsenv/eslint-config": "16.0.9",
59
48
  "@jsenv/github-release-package": "1.2.3",
60
- "@jsenv/importmap-eslint-resolver": "5.1.2",
61
- "@jsenv/importmap-node-module": "2.4.1",
49
+ "@jsenv/importmap-eslint-resolver": "5.2.1",
50
+ "@jsenv/importmap-node-module": "2.8.0",
62
51
  "@jsenv/package-publish": "1.6.2",
63
52
  "@jsenv/performance-impact": "2.2.1",
64
- "@jsenv/prettier-check-project": "5.6.1",
65
- "eslint": "7.32.0",
66
- "eslint-plugin-import": "2.25.2",
67
- "prettier": "2.4.1"
53
+ "eslint": "8.4.1",
54
+ "eslint-plugin-import": "2.25.3",
55
+ "prettier": "2.5.1"
68
56
  }
69
- }
57
+ }
@@ -1,33 +1,19 @@
1
1
  import { collectFiles } from "./collectFiles.js"
2
2
 
3
- export const listFilesMatching = async (
4
- patterns,
3
+ export const listFilesMatching = async ({
5
4
  directoryUrl = process.cwd(),
5
+ patterns,
6
6
  signal,
7
- ) => {
8
- if (typeof patterns === "string") {
9
- patterns = [patterns]
10
- } else if (Array.isArray(patterns)) {
11
- throw new TypeError(
12
- `patterns must be a string or an array of strings, got ${patterns}`,
13
- )
7
+ }) => {
8
+ if (typeof patterns !== "object" || patterns === null) {
9
+ throw new TypeError(`patterns must be an object, got ${patterns}`)
14
10
  }
15
11
 
16
- const patternMap = {}
17
- patterns.forEach((pattern, index) => {
18
- if (typeof pattern !== "string") {
19
- throw new TypeError(
20
- `every pattern must be a string, found ${pattern} at index ${index}`,
21
- )
22
- }
23
- patternMap[pattern] = true
24
- })
25
-
26
12
  const fileDatas = await collectFiles({
27
13
  signal,
28
14
  directoryUrl,
29
15
  structuredMetaMap: {
30
- matches: patternMap,
16
+ matches: patterns,
31
17
  },
32
18
  predicate: ({ matches }) => matches,
33
19
  })