项目文件夹

文件
wehub-resource-sync 070959e133
landing-page-staging / Deploy landing page to staging (push) Has been skipped
landing-page-ci / Validate landing page (push) Failing after 4s
visual-baseline / Capture visual baselines (push) Has been cancelled
bake-plugin-previews / Bake plugin previews (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:00:47 +08:00

41 行
1.2 KiB
TypeScript

import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { afterEach, describe, expect, it } from 'vitest';
import { listFiles } from '../src/projects.js';
const tempRoots: string[] = [];
async function makeProjectsRoot() {
const root = await mkdtemp(path.join(tmpdir(), 'od-project-files-'));
tempRoots.push(root);
return path.join(root, 'projects');
}
afterEach(async () => {
await Promise.all(tempRoots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
});
describe('listFiles', () => {
it('includes the absolute local path for each visible project file', async () => {
const projectsRoot = await makeProjectsRoot();
const projectId = 'project-1';
const projectDir = path.join(projectsRoot, projectId);
const filePath = path.join(projectDir, 'alpha.html');
await mkdir(projectDir, { recursive: true });
await writeFile(filePath, '<!doctype html>');
const files = await listFiles(projectsRoot, projectId);
expect(files).toEqual([
expect.objectContaining({
name: 'alpha.html',
path: 'alpha.html',
localPath: filePath,
}),
]);
});
});