2024-02-22 23:05:02 +07:00
|
|
|
import fs from "node:fs";
|
|
|
|
import path from "node:path";
|
2024-02-22 20:59:20 +00:00
|
|
|
import cuid2 from "@paralleldrive/cuid2";
|
2024-02-26 10:48:17 +00:00
|
|
|
import { ProjectSchema } from "../db/schema/project";
|
2024-02-22 23:05:02 +07:00
|
|
|
|
|
|
|
export const fileExists = (path: string) => {
|
|
|
|
try {
|
|
|
|
fs.accessSync(path, fs.constants.F_OK);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-26 10:48:17 +00:00
|
|
|
export const getProjectDir = (project: ProjectSchema) => {
|
|
|
|
return path.resolve(process.cwd(), "storage/tmp", project.slug);
|
2024-02-22 23:05:02 +07:00
|
|
|
};
|
2024-02-22 20:59:20 +00:00
|
|
|
|
|
|
|
export const uid = cuid2.init({
|
|
|
|
length: 8,
|
|
|
|
});
|