Skip to content

Commit

Permalink
test: use pkg typings entries for tsd tests (#780)
Browse files Browse the repository at this point in the history
* test: use pkg typings entries for dts test

relates #779

* fix: fix globby types resolution

closes #779
  • Loading branch information
antongolub authored Apr 15, 2024
1 parent 00d1b74 commit d397293
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 32 deletions.
10 changes: 0 additions & 10 deletions src/goods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import { type Duration, isString, parseDuration } from './util.js'
import {
chalk,
minimist,
globbyModule,
GlobbyOptions,
nodeFetch,
RequestInfo,
RequestInit,
Expand All @@ -35,14 +33,6 @@ export function updateArgv(args: string[]) {
;(global as any).argv = argv
}

export const globby = Object.assign(function globby(
patterns: string | readonly string[],
options?: GlobbyOptions
) {
return globbyModule.globby(patterns, options)
}, globbyModule) as (typeof globbyModule)['globby'] & typeof globbyModule
export const glob = globby

export function sleep(duration: Duration) {
return new Promise((resolve) => {
setTimeout(resolve, parseDuration(duration))
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ import { ProcessPromise } from './core.js'

export * from './core.js'
export * from './goods.js'
export { minimist, chalk, fs, which, YAML, ps } from './vendor.js'
export {
minimist,
chalk,
fs,
which,
YAML,
ps,
glob,
glob as globby,
} from './vendor.js'

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

Expand Down
12 changes: 11 additions & 1 deletion src/vendor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import {
convertPathToPattern,
globby,
globbySync,
globbyStream,
Expand All @@ -21,7 +22,9 @@ import {
isGitIgnoredSync,
isGitIgnored,
isDynamicPattern,
type Options as GlobbyOptions,
} from 'globby'

import * as yaml from 'yaml'
import * as _fs from 'fs-extra'
import type { fetch } from 'node-fetch-native'
Expand All @@ -33,6 +36,7 @@ export type RequestInfo = Parameters<typeof fetch>[0]
export type RequestInit = Parameters<typeof fetch>[1]

export const globbyModule = {
convertPathToPattern,
globby,
globbySync,
globbyStream,
Expand All @@ -43,6 +47,13 @@ export const globbyModule = {
isDynamicPattern,
}

export const glob = Object.assign(function globby(
patterns: string | readonly string[],
options?: GlobbyOptions
) {
return globbyModule.globby(patterns, options)
}, globbyModule) as (typeof globbyModule)['globby'] & typeof globbyModule

export const YAML: {
parse(text: string): any
stringify(object: any): string
Expand All @@ -51,7 +62,6 @@ export const YAML: {
export const fs: typeof import('fs-extra') = _fs

export { depseekSync as depseek } from 'depseek'
export { type Options as GlobbyOptions } from 'globby'
export { default as chalk, type ChalkInstance } from 'chalk'
export { default as which } from 'which'
export { default as minimist } from 'minimist'
Expand Down
2 changes: 1 addition & 1 deletion test-d/core.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import assert from 'node:assert'
import { Readable, Writable } from 'node:stream'
import { expectType } from 'tsd'
import { $, ProcessPromise, ProcessOutput, within } from '../src/core.js'
import { $, ProcessPromise, ProcessOutput, within } from 'zx'

let p = $`cmd`
assert(p instanceof ProcessPromise)
Expand Down
15 changes: 0 additions & 15 deletions test-d/experimental.test-d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test-d/globals.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import assert from 'node:assert'
import { expectType } from 'tsd'
import '../src/globals.js'
import 'zx/globals'

let p = $`cmd`
assert(p instanceof ProcessPromise)
Expand Down
3 changes: 1 addition & 2 deletions test-d/goods.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
// limitations under the License.

import { expectType } from 'tsd'
import { $ } from '../src/core.js'
import { echo, sleep, spinner, retry, expBackoff } from '../src/goods.js'
import { $, echo, sleep, spinner, retry, expBackoff } from 'zx'

echo`Date is ${await $`date`}`
echo('Hello, world!')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/js-project/package-lock.json

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

0 comments on commit d397293

Please sign in to comment.