Skip to content

Commit

Permalink
Fix echo signature and add tsd test
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Jun 27, 2022
1 parent 35ea780 commit 663ee00
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -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"
},
Expand All @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions src/goods.ts
Expand Up @@ -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(
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions 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)

0 comments on commit 663ee00

Please sign in to comment.