Skip to content

Commit d397293

Browse files
authored
test: use pkg typings entries for tsd tests (google#780)
* test: use pkg typings entries for dts test relates google#779 * fix: fix globby types resolution closes google#779
1 parent 00d1b74 commit d397293

File tree

8 files changed

+25
-32
lines changed

8 files changed

+25
-32
lines changed

src/goods.ts

-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { type Duration, isString, parseDuration } from './util.js'
1919
import {
2020
chalk,
2121
minimist,
22-
globbyModule,
23-
GlobbyOptions,
2422
nodeFetch,
2523
RequestInfo,
2624
RequestInit,
@@ -35,14 +33,6 @@ export function updateArgv(args: string[]) {
3533
;(global as any).argv = argv
3634
}
3735

38-
export const globby = Object.assign(function globby(
39-
patterns: string | readonly string[],
40-
options?: GlobbyOptions
41-
) {
42-
return globbyModule.globby(patterns, options)
43-
}, globbyModule) as (typeof globbyModule)['globby'] & typeof globbyModule
44-
export const glob = globby
45-
4636
export function sleep(duration: Duration) {
4737
return new Promise((resolve) => {
4838
setTimeout(resolve, parseDuration(duration))

src/index.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ import { ProcessPromise } from './core.js'
1616

1717
export * from './core.js'
1818
export * from './goods.js'
19-
export { minimist, chalk, fs, which, YAML, ps } from './vendor.js'
19+
export {
20+
minimist,
21+
chalk,
22+
fs,
23+
which,
24+
YAML,
25+
ps,
26+
glob,
27+
glob as globby,
28+
} from './vendor.js'
2029

2130
export { type Duration, quote, quotePowerShell } from './util.js'
2231

src/vendor.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import {
16+
convertPathToPattern,
1617
globby,
1718
globbySync,
1819
globbyStream,
@@ -21,7 +22,9 @@ import {
2122
isGitIgnoredSync,
2223
isGitIgnored,
2324
isDynamicPattern,
25+
type Options as GlobbyOptions,
2426
} from 'globby'
27+
2528
import * as yaml from 'yaml'
2629
import * as _fs from 'fs-extra'
2730
import type { fetch } from 'node-fetch-native'
@@ -33,6 +36,7 @@ export type RequestInfo = Parameters<typeof fetch>[0]
3336
export type RequestInit = Parameters<typeof fetch>[1]
3437

3538
export const globbyModule = {
39+
convertPathToPattern,
3640
globby,
3741
globbySync,
3842
globbyStream,
@@ -43,6 +47,13 @@ export const globbyModule = {
4347
isDynamicPattern,
4448
}
4549

50+
export const glob = Object.assign(function globby(
51+
patterns: string | readonly string[],
52+
options?: GlobbyOptions
53+
) {
54+
return globbyModule.globby(patterns, options)
55+
}, globbyModule) as (typeof globbyModule)['globby'] & typeof globbyModule
56+
4657
export const YAML: {
4758
parse(text: string): any
4859
stringify(object: any): string
@@ -51,7 +62,6 @@ export const YAML: {
5162
export const fs: typeof import('fs-extra') = _fs
5263

5364
export { depseekSync as depseek } from 'depseek'
54-
export { type Options as GlobbyOptions } from 'globby'
5565
export { default as chalk, type ChalkInstance } from 'chalk'
5666
export { default as which } from 'which'
5767
export { default as minimist } from 'minimist'

test-d/core.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import assert from 'node:assert'
1616
import { Readable, Writable } from 'node:stream'
1717
import { expectType } from 'tsd'
18-
import { $, ProcessPromise, ProcessOutput, within } from '../src/core.js'
18+
import { $, ProcessPromise, ProcessOutput, within } from 'zx'
1919

2020
let p = $`cmd`
2121
assert(p instanceof ProcessPromise)

test-d/experimental.test-d.ts

-15
This file was deleted.

test-d/globals.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import assert from 'node:assert'
1616
import { expectType } from 'tsd'
17-
import '../src/globals.js'
17+
import 'zx/globals'
1818

1919
let p = $`cmd`
2020
assert(p instanceof ProcessPromise)

test-d/goods.test-d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
// limitations under the License.
1414

1515
import { expectType } from 'tsd'
16-
import { $ } from '../src/core.js'
17-
import { echo, sleep, spinner, retry, expBackoff } from '../src/goods.js'
16+
import { $, echo, sleep, spinner, retry, expBackoff } from 'zx'
1817

1918
echo`Date is ${await $`date`}`
2019
echo('Hello, world!')

test/fixtures/js-project/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)