@avleon/cli
Version:
> **🚧 This project is in active development.** > > It is **not stable** and **not ready** for live environments. > Use **only for testing, experimentation, or internal evaluation**. > > ####❗ Risks of using this in production: > > - 🔄 Breaking changes
31 lines (30 loc) • 973 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fh = void 0;
exports.getLastPart = getLastPart;
exports.getFilePathWithoutName = getFilePathWithoutName;
exports.resolveNames = resolveNames;
const filenameFromPath = (fpath) => fpath.split('/')[fpath.split('/').length - 1];
function getLastPart(str, separator) {
if (!str.includes(separator))
return str;
const parts = str.split(separator);
return parts.at(-1);
}
function getFilePathWithoutName(fpath) {
const parts = fpath.split("/");
if (parts.length < 2) {
return "";
}
parts.splice(parts.length - 1, 1);
return parts.join("/");
}
function resolveNames(name, exclude) {
const parsedName = name.replace(exclude, '');
return {
className: parsedName.charAt(0).toUpperCase() + name.slice(1),
fileName: parsedName.toLowerCase(),
varName: parsedName.toLowerCase(),
};
}
exports.fh = { filenameFromPath };