UNPKG

mstr-viz

Version:

A new dev tool for creating custom visualizations

15 lines (10 loc) 499 B
const fs = require('fs'); const getFileExtension = filePathWithoutExtension => { const possibleExtensions = ['.js', '.jsx', '.ts', '.tsx']; // eslint-disable-next-line no-restricted-syntax for (const extension of possibleExtensions) { if (fs.existsSync(filePathWithoutExtension + extension)) return extension; } throw new Error(`${filePathWithoutExtension} file doesnt not exists with any of the following extensions: ${possibleExtensions}`); }; module.exports = getFileExtension;