diff --git a/scripts/build-tests.mjs b/scripts/build-tests.mjs index db21635565..eceb98ece9 100644 --- a/scripts/build-tests.mjs +++ b/scripts/build-tests.mjs @@ -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' diff --git a/src/goods.ts b/src/goods.ts index 97af053d19..090cef8d63 100644 --- a/src/goods.ts +++ b/src/goods.ts @@ -33,7 +33,7 @@ export function updateArgv(args: string[]) { Object.assign(argv, minimist(args)) } -export function sleep(duration: Duration): Promise { +export function sleep(duration: Duration): Promise { return new Promise((resolve) => { setTimeout(resolve, parseDuration(duration)) }) @@ -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( diff --git a/test/vendor-export.test.js b/test/vendor-export.test.js index 56cd620d16..864a4570d5 100644 --- a/test/vendor-export.test.js +++ b/test/vendor-export.test.js @@ -18,6 +18,7 @@ import { chalk, depseek, fs, + glob, minimist, ps, which, @@ -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', () => {