UNPKG

@kadena/kadena-cli

Version:

Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)

26 lines 906 B
import path from 'path'; /** * Removes the file extension from a given filename. * @param {string} filename - The filename from which the extension is to be removed. * @returns {string} The filename without the extension. */ export function removeExtension(filename) { return filename.replace(/\.[^/.]+$/, ''); } export function removeAfterFirstDot(filename) { const dotIndex = filename.indexOf('.'); return dotIndex === -1 ? filename : filename.substring(0, dotIndex); } const isChildPath = (parent, child) => { const relative = path.relative(parent, child); return relative ? !relative.startsWith('..') && !path.isAbsolute(relative) : false; }; export function relativeToCwd(filepath) { const cwd = process.cwd(); return isChildPath(cwd, filepath) ? path.relative(process.cwd(), filepath) : filepath; } //# sourceMappingURL=path.util.js.map