30 lines
950 B
TypeScript
30 lines
950 B
TypeScript
import fs = require("fs-extra");
|
|
import path, { resolve } from "path";
|
|
import dotenv from "dotenv";
|
|
import os from "os";
|
|
|
|
dotenv.config({
|
|
path: resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`),
|
|
});
|
|
|
|
const RootDirectory = process.env.MEDIA_PATH!.replace("~", os.homedir);
|
|
export const FolderPaths = {
|
|
Root: RootDirectory,
|
|
Jobs: path.join(RootDirectory, "Jobs"),
|
|
Vendors: path.join(RootDirectory, "Vendors"),
|
|
ThumbsSubDir: "/thumbs",
|
|
};
|
|
|
|
export default function InitServer() {
|
|
console.log(
|
|
`Root Media Path: ${FolderPaths.Root}`,
|
|
fs.pathExistsSync(FolderPaths.Root)
|
|
);
|
|
console.log(`Ensuring Root media path exists: ${FolderPaths.Root}`);
|
|
fs.ensureDirSync(FolderPaths.Root);
|
|
console.log(`Ensuring Jobs media path exists: ${FolderPaths.Jobs}`);
|
|
fs.ensureDirSync(FolderPaths.Jobs);
|
|
console.log(`Ensuring Vendors media path exists: ${FolderPaths.Vendors}`);
|
|
fs.ensureDirSync(FolderPaths.Vendors);
|
|
}
|