Skip to content

Commit

Permalink
chore: minor code imprs (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Dec 21, 2024
1 parent c4e4902 commit dda74fc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
11 changes: 10 additions & 1 deletion scripts/build-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ import path from 'node:path'
import * as vendor from '../build/vendor.js'

const root = path.resolve(new URL(import.meta.url).pathname, '../..')
const apis = ['chalk', 'depseek', 'fs', 'minimist', 'ps', 'which', 'YAML']
const apis = [
'chalk',
'depseek',
'fs',
'glob',
'minimist',
'ps',
'which',
'YAML',
]
const copyright = await fs.readFileSync(
path.resolve(root, 'test/fixtures/copyright.txt'),
'utf8'
Expand Down
9 changes: 4 additions & 5 deletions src/goods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function updateArgv(args: string[]) {
Object.assign(argv, minimist(args))
}

export function sleep(duration: Duration): Promise<unknown> {
export function sleep(duration: Duration): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, parseDuration(duration))
})
Expand All @@ -58,10 +58,9 @@ export function echo(pieces: TemplateStringsArray, ...args: any[]) {
}

function stringify(arg: ProcessOutput | any) {
if (arg instanceof ProcessOutput) {
return arg.toString().replace(/\n$/, '')
}
return `${arg}`
return arg instanceof ProcessOutput
? arg.toString().replace(/\n$/, '')
: `${arg}`
}

export async function question(
Expand Down
17 changes: 17 additions & 0 deletions test/vendor-export.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
chalk,
depseek,
fs,
glob,
minimist,
ps,
which,
Expand Down Expand Up @@ -198,6 +199,22 @@ describe('vendor fs API ', () => {
})
})

describe('vendor glob API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof glob, 'function')
assert.equal(typeof glob.convertPathToPattern, 'function', 'glob.convertPathToPattern')
assert.equal(typeof glob.globby, 'function', 'glob.globby')
assert.equal(typeof glob.globbySync, 'function', 'glob.globbySync')
assert.equal(typeof glob.globbyStream, 'function', 'glob.globbyStream')
assert.equal(typeof glob.generateGlobTasksSync, 'function', 'glob.generateGlobTasksSync')
assert.equal(typeof glob.generateGlobTasks, 'function', 'glob.generateGlobTasks')
assert.equal(typeof glob.isGitIgnoredSync, 'function', 'glob.isGitIgnoredSync')
assert.equal(typeof glob.isGitIgnored, 'function', 'glob.isGitIgnored')
assert.equal(typeof glob.isDynamicPattern, 'function', 'glob.isDynamicPattern')
})
})

describe('vendor minimist API ', () => {
// prettier-ignore
test('exports', () => {
Expand Down

0 comments on commit dda74fc

Please sign in to comment.