@remotion/bundler
Version:
Bundle Remotion compositions using Webpack
31 lines (30 loc) • 1.39 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePublicDir = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const validatePublicDir = (p) => {
const { root } = node_path_1.default.parse(process.cwd());
if (p === root) {
throw new Error(`The public directory was specified as "${p}", which is the root directory. This is not allowed.`);
}
try {
const stat = node_fs_1.default.lstatSync(p);
if (!stat.isDirectory()) {
throw new Error(`The public directory was specified as "${p}", and while this path exists on the filesystem, it is not a directory.`);
}
}
catch (_a) {
// Path does not exist
// Check if the parent path exists
const parentPath = node_path_1.default.dirname(p);
const exists = node_fs_1.default.existsSync(parentPath);
if (!exists) {
throw new Error(`The public directory was specified as "${p}", but this folder does not exist and the parent directory "${parentPath}" does also not exist. Create at least the parent directory.`);
}
}
};
exports.validatePublicDir = validatePublicDir;