Skip to content

Commit 93836c4

Browse files
committed
feat!: replace tinyglobby with built-in fs.glob
1 parent 7622c1a commit 93836c4

5 files changed

Lines changed: 22 additions & 15 deletions

File tree

cli.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import fs from 'node:fs/promises'
33
import streamConsumers from 'node:stream/consumers'
44
import { parseArgs } from 'node:util'
5-
import { glob } from 'tinyglobby'
65
import sortPackageJson from './index.js'
76
import Reporter from './reporter.js'
87
import packageJson from './package.json' with { type: 'json' }
@@ -71,7 +70,11 @@ async function sortPackageJsonFile(file, reporter, isCheck) {
7170
}
7271

7372
async function sortPackageJsonFiles(patterns, { ignore, ...options }) {
74-
const files = await glob(patterns, { ignore })
73+
const results = await Array.fromAsync(fs.glob(patterns, { exclude: ignore }))
74+
const files =
75+
process.platform === 'win32'
76+
? results.map((result) => result.replaceAll('\\', '/'))
77+
: results
7578

7679
const reporter = new Reporter(options)
7780
const { isCheck } = options

package-lock.json

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@
7979
"git-hooks-list": "^4.1.1",
8080
"is-plain-obj": "^4.1.0",
8181
"semver": "^7.7.3",
82-
"sort-object-keys": "^2.0.1",
83-
"tinyglobby": "^0.2.15"
82+
"sort-object-keys": "^2.0.1"
8483
},
8584
"devDependencies": {
8685
"@commitlint/cli": "^20.1.0",

tests/snapshots/cli.js.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ Generated by [AVA](https://avajs.dev).
738738
result: {
739739
errorCode: null,
740740
stderr: '',
741-
stdout: `bad-1/package.json is sorted!␊
742-
bad-2/package.json is sorted!␊
741+
stdout: `bad-2/package.json is sorted!␊
742+
bad-1/package.json is sorted!␊
743743
744744
Found 2 files.␊
745745
2 files successfully sorted.␊
@@ -783,8 +783,8 @@ Generated by [AVA](https://avajs.dev).
783783
result: {
784784
errorCode: 1,
785785
stderr: '',
786-
stdout: `bad-1/package.json␊
787-
bad-2/package.json␊
786+
stdout: `bad-2/package.json␊
787+
bad-1/package.json␊
788788
789789
Found 2 files.␊
790790
2 files were not sorted.␊
@@ -930,8 +930,8 @@ Generated by [AVA](https://avajs.dev).
930930
result: {
931931
errorCode: null,
932932
stderr: '',
933-
stdout: `bad-1/package.json is sorted!␊
934-
bad-2/package.json is sorted!␊
933+
stdout: `bad-2/package.json is sorted!␊
934+
bad-1/package.json is sorted!␊
935935
936936
Found 4 files.␊
937937
2 files successfully sorted.␊
@@ -1060,8 +1060,8 @@ Generated by [AVA](https://avajs.dev).
10601060
result: {
10611061
errorCode: 1,
10621062
stderr: '',
1063-
stdout: `bad-1/package.json␊
1064-
bad-2/package.json␊
1063+
stdout: `bad-2/package.json␊
1064+
bad-1/package.json␊
10651065
10661066
Found 4 files.␊
10671067
2 files were not sorted.␊

tests/snapshots/cli.js.snap

-3 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)