0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00
astro/packages/integrations/vercel/src/lib/fs.ts
Juan Martín Seery c1f991408b
fix(vercel): now works with monorepos (#5033)
* Upgraded nft

* Handle monorepo better

* Changeset

* Fixed common ancestor

* Fixed outdir
2022-10-10 11:37:03 -04:00

17 lines
553 B
TypeScript

import type { PathLike } from 'node:fs';
import * as fs from 'node:fs/promises';
export async function writeJson<T>(path: PathLike, data: T) {
await fs.writeFile(path, JSON.stringify(data), { encoding: 'utf-8' });
}
export async function removeDir(dir: PathLike) {
await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
}
export async function emptyDir(dir: PathLike): Promise<void> {
await removeDir(dir);
await fs.mkdir(dir, { recursive: true });
}
export const getVercelOutput = (root: URL) => new URL('./.vercel/output/', root);