chore: use readdir internally rather than globby

This commit is contained in:
Daniel Roe 2024-06-24 14:33:47 +01:00
parent c45131b46f
commit 0ef8febb8c
No known key found for this signature in database
GPG Key ID: CBC814C393D93268
2 changed files with 10 additions and 14 deletions

View File

@ -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)
}

View File

@ -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) })),
)
}