website-auditfy
Version:
> Tool for validate your project on SEO, HTML, CSS, JS, TS, Performance, Security and A11Y
29 lines • 1.18 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.File = void 0;
const node_path_1 = __importDefault(require("node:path"));
const path_utils_1 = require("../utils/path.utils");
const node_fs_1 = require("node:fs");
class File {
constructor() { }
static create(filePath) {
const file = new File();
const normalizePath = path_utils_1.PathUtils.getNormalizePath(filePath);
const result = (0, node_fs_1.statSync)(normalizePath);
if (!result.isFile()) {
throw new Error("Exception of file");
}
file.dir = node_path_1.default.dirname(normalizePath);
file.filename = node_path_1.default.basename(normalizePath);
file.extension = node_path_1.default.extname(normalizePath);
file.relativePath = `${file.dir}/${file.filename}`;
file.absolutePath = normalizePath;
file.pathWithExtension = `file://${file.absolutePath}`;
return file;
}
}
exports.File = File;
//# sourceMappingURL=file.model.js.map