Commit d397293

Anton Golub <antongolub@antongolub.com>
2024-04-15 19:51:42
test: use pkg typings entries for tsd tests (#780)
* test: use pkg typings entries for dts test relates #779 * fix: fix globby types resolution closes #779
1 parent 00d1b74
src/goods.ts
@@ -19,8 +19,6 @@ import { type Duration, isString, parseDuration } from './util.js'
 import {
   chalk,
   minimist,
-  globbyModule,
-  GlobbyOptions,
   nodeFetch,
   RequestInfo,
   RequestInit,
@@ -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))
src/index.ts
@@ -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'
 
src/vendor.ts
@@ -13,6 +13,7 @@
 // limitations under the License.
 
 import {
+  convertPathToPattern,
   globby,
   globbySync,
   globbyStream,
@@ -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'
@@ -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,
@@ -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
@@ -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'
test/fixtures/js-project/package-lock.json
@@ -9,7 +9,7 @@
       }
     },
     "../../..": {
-      "version": "8.0.0",
+      "version": "8.0.1",
       "license": "Apache-2.0",
       "bin": {
         "zx": "build/cli.js"
test-d/core.test-d.ts
@@ -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)
test-d/experimental.test-d.ts
@@ -1,15 +0,0 @@
-// Copyright 2022 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import { expectType } from 'tsd'
test-d/globals.test-d.ts
@@ -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)
test-d/goods.test-d.ts
@@ -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!')