From 0ef8febb8c4369fbf130c64a22880013de62f231 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 24 Jun 2024 14:33:47 +0100 Subject: [PATCH] chore: use `readdir` internally rather than `globby` --- scripts/_utils.ts | 6 +++--- test/prepare.ts | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/_utils.ts b/scripts/_utils.ts index 9e7737f506..87d783a868 100644 --- a/scripts/_utils.ts +++ b/scripts/_utils.ts @@ -2,7 +2,6 @@ import { execSync } from 'node:child_process' import { promises as fsp } from 'node:fs' import { $fetch } from 'ofetch' import { resolve } from 'pathe' -import { globby } from 'globby' import { execaSync } from 'execa' import { determineSemverChange, getGitDiff, loadChangelogConfig, parseCommits } from 'changelogen' @@ -43,12 +42,13 @@ export async function loadPackage (dir: string) { export async function loadWorkspace (dir: string) { const workspacePkg = await loadPackage(dir) - const pkgDirs = (await globby(['packages/*'], { onlyDirectories: true })).sort() + const pkgDirs = await fsp.readdir('packages', { withFileTypes: true }) const packages: Package[] = [] for (const pkgDir of pkgDirs) { - const pkg = await loadPackage(pkgDir) + if (!pkgDir.isDirectory()) { continue } + const pkg = await loadPackage(resolve('packages', pkgDir.name)) if (!pkg.data.name) { continue } packages.push(pkg) } diff --git a/test/prepare.ts b/test/prepare.ts index e4442a18ac..7943bf0a94 100644 --- a/test/prepare.ts +++ b/test/prepare.ts @@ -1,26 +1,22 @@ import { fileURLToPath } from 'node:url' -import { rm } from 'node:fs/promises' - -import { globby } from 'globby' +import { readdir, rm } from 'node:fs/promises' import { execa } from 'execa' +import { join } from 'pathe' async function initTesting () { - const dirs = await globby('*', { - onlyDirectories: true, - cwd: fileURLToPath(new URL('./fixtures', import.meta.url)), - absolute: true, - }) + const fixturesDir = fileURLToPath(new URL('./fixtures', import.meta.url)) + const dirs = await readdir(fixturesDir) await Promise.all([ // clear nuxt build files - ...dirs.map(dir => rm(`${dir}/.nuxt`, { force: true, recursive: true })), + ...dirs.map(dir => rm(join(fixturesDir, `${dir}/.nuxt`), { force: true, recursive: true })), // clear vite cache - ...dirs.map(dir => rm(`${dir}/node_modules/.cache`, { force: true, recursive: true })), + ...dirs.map(dir => rm(join(fixturesDir, `${dir}/node_modules/.cache`), { force: true, recursive: true })), ]) await Promise.all( - dirs.map(dir => execa('pnpm', ['nuxi', 'prepare'], { cwd: dir })), + dirs.map(dir => execa('pnpm', ['nuxi', 'prepare'], { cwd: join(fixturesDir, dir) })), ) }