feat: enhance deployment process with improved error handling and logging
This commit is contained in:
24
src/lib/tempdir.ts
Normal file
24
src/lib/tempdir.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import type { WPopContext } from "./context";
|
||||
|
||||
export type TempDir = {
|
||||
path: string;
|
||||
cleanup: () => void;
|
||||
};
|
||||
|
||||
export function createTempDir(context: WPopContext, prefix: string): TempDir {
|
||||
if (context.dryRun) {
|
||||
return {
|
||||
path: join(tmpdir(), prefix),
|
||||
cleanup: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
const path = mkdtempSync(join(tmpdir(), `${prefix}-`));
|
||||
return {
|
||||
path,
|
||||
cleanup: () => rmSync(path, { force: true, recursive: true }),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user