Commit 663ee00
Changed files (3)
src/goods.ts
@@ -29,7 +29,7 @@ export { default as os } from 'node:os'
export let argv = minimist(process.argv.slice(2))
export function updateArgv(params: { sliceAt: number }) {
argv = minimist(process.argv.slice(params.sliceAt))
- global.argv = argv
+ ;(global as any).argv = argv
}
export const globby = Object.assign(function globby(
@@ -52,7 +52,7 @@ export async function fetch(url: RequestInfo, init?: RequestInit) {
return nodeFetch(url, init)
}
-// A console.log() alternative which can take ProcessOutput.
+export function echo(...args: any[]): void
export function echo(pieces: TemplateStringsArray, ...args: any[]) {
let msg
let lastIdx = pieces.length - 1
test-d/goods.test-d.ts
@@ -0,0 +1,22 @@
+// 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 { $ } from '../src/core.js'
+import { echo, sleep } from '../src/goods.js'
+
+echo`Date is ${await $`date`}`
+echo('Hello, world!')
+
+await sleep('1s')
+await sleep(1000)
package.json
@@ -39,6 +39,7 @@
"fmt:check": "prettier --check .",
"build": "tsc",
"test": "tsc && PATH=$(env -i bash -c 'echo $PATH') node_modules/.bin/uvu test -i fixtures",
+ "tsd": "tsd",
"coverage": "c8 --check-coverage npm test -- -i package",
"mutation": "stryker run"
},
@@ -61,6 +62,7 @@
"@stryker-mutator/core": "^6.0.2",
"c8": "^7.11.3",
"prettier": "^2.7.0",
+ "tsd": "^0.21.0",
"typescript": "^4.8.0-dev.20220529",
"uvu": "^0.5.3"
},