datainout
Version:
Import and reports data
14 lines (13 loc) • 466 B
JavaScript
// src/helpers/get-file-extension.ts
function getFileExtension(path) {
const fileName = path.replace("\\", "/").split("/").pop();
if (!fileName) throw new Error(`Path [${path}] invalid`);
const extension = fileName.split(".").pop();
if (!extension) throw new Error(`Path [${path}] invalid`);
if (extension === "js") return "js";
else if (extension === "ts") return "ts";
else throw new Error(`Path [${path}] invalid`);
}
export {
getFileExtension
};