ocat-lang
Version:
A programming language for the web design and development
28 lines (27 loc) • 904 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.processPath = void 0;
const loadPathRules = (config) => {
var _a;
return (_a = config.path) !== null && _a !== void 0 ? _a : null;
};
const replacePlaceholders = (value) => {
const projectRoot = process.cwd();
const projectName = projectRoot.split("/").pop() || "";
return value
.replace("${projectRoot}", projectRoot)
.replace("${projectName}", projectName);
};
const applyPathRules = (wppath, rules) => {
let ppath = wppath;
for (const key in rules) {
const replacedValue = replacePlaceholders(rules[key]);
ppath = ppath.replace(key, replacedValue);
}
return ppath;
};
const processPath = (wppath, config) => {
const rules = loadPathRules(config);
return rules ? applyPathRules(wppath, rules) : wppath;
};
exports.processPath = processPath;