Skip to content

Commit 8095c6b

Browse files
authored
Merge branch 'main' into zx-lite-publish
2 parents 5f78aa6 + 9e2ce2e commit 8095c6b

8 files changed

+27
-19
lines changed

.size-limit.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{
3838
"name": "vendor",
3939
"path": "build/vendor-*",
40-
"limit": "767.1 kB",
40+
"limit": "767.12 kB",
4141
"brotli": false,
4242
"gzip": false
4343
},

docs/api.md

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ The [globby](https://github.com/sindresorhus/globby) package.
268268

269269
```js
270270
const packages = await glob(['package.json', 'packages/*/package.json'])
271+
const markdowns = glob.sync('*.md') // sync API shortcut
271272
```
272273

273274
## `which()`

src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const argv: minimist.ParsedArgs = parseArgv(process.argv.slice(2), {
8989
stopEarly: true,
9090
parseBoolean: true,
9191
camelCase: true,
92-
})
92+
}, resolveDefaults({} as any, 'ZX_', process.env, new Set(['env', 'eval', 'install', 'registry'])))
9393

9494
export async function main(): Promise<void> {
9595
await import('./globals.js')

src/core.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ const EOL = Buffer.from(_EOL)
7575
const BR_CC = '\n'.charCodeAt(0)
7676
const SIGTERM = 'SIGTERM'
7777
const ENV_PREFIX = 'ZX_'
78+
const ENV_ALLOWED: Set<string> = new Set([
79+
'cwd',
80+
'preferLocal',
81+
'detached',
82+
'verbose',
83+
'quiet',
84+
'timeout',
85+
'timeoutSignal',
86+
'killSignal',
87+
'prefix',
88+
'postfix',
89+
'shell',
90+
])
7891
const storage = new AsyncLocalStorage<Options>()
7992

8093
function getStore() {
@@ -931,22 +944,9 @@ const promisifyStream = <S extends Writable>(
931944
export function resolveDefaults(
932945
defs: Options = defaults,
933946
prefix: string = ENV_PREFIX,
934-
env = process.env
947+
env = process.env,
948+
allowed = ENV_ALLOWED
935949
): Options {
936-
const allowed = new Set([
937-
'cwd',
938-
'preferLocal',
939-
'detached',
940-
'verbose',
941-
'quiet',
942-
'timeout',
943-
'timeoutSignal',
944-
'killSignal',
945-
'prefix',
946-
'postfix',
947-
'shell',
948-
])
949-
950950
return Object.entries(env).reduce<Options>((m, [k, v]) => {
951951
if (v && k.startsWith(prefix)) {
952952
const _k = toCamelCase(k.slice(prefix.length))

src/goods.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ type ArgvOpts = minimist.Opts & { camelCase?: boolean; parseBoolean?: boolean }
3535

3636
export const parseArgv = (
3737
args: string[] = process.argv.slice(2),
38-
opts: ArgvOpts = {}
38+
opts: ArgvOpts = {},
39+
defs: Record<string, any> = {}
3940
): minimist.ParsedArgs =>
4041
Object.entries(minimist(args, opts)).reduce<minimist.ParsedArgs>(
4142
(m, [k, v]) => {
@@ -45,7 +46,7 @@ export const parseArgv = (
4546
m[_k] = _v
4647
return m
4748
},
48-
{} as minimist.ParsedArgs
49+
{ ...defs } as minimist.ParsedArgs
4950
)
5051

5152
export function updateArgv(args?: string[], opts?: ArgvOpts) {

src/vendor-extra.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const createRequire = _createRequire as unknown as (
4141
export const globbyModule = {
4242
convertPathToPattern,
4343
globby,
44+
sync: globbySync,
4445
globbySync,
4546
globbyStream,
4647
generateGlobTasksSync,

test/goods.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ describe('goods', () => {
156156
camelCase: true,
157157
parseBoolean: true,
158158
alias: { a: 'aaa' },
159+
},
160+
{
161+
def: 'def',
159162
}
160163
),
161164
{
@@ -170,6 +173,7 @@ describe('goods', () => {
170173
b4: false,
171174
b5: true,
172175
b6: true,
176+
def: 'def',
173177
}
174178
)
175179
})

test/vendor.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe('vendor API', () => {
3333

3434
test('globby() works', async () => {
3535
assert.deepEqual(await glob('*.md'), ['README.md'])
36+
assert.deepEqual(glob.sync('*.md'), ['README.md'])
3637
})
3738

3839
test('fetch() works', async () => {

0 commit comments

Comments
 (0)