@vitjs/core
Version:
@vitjs/core
25 lines (24 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTSFile = exports.isDynamicRoute = exports.getGlobalFiles = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
/**
* get global file like (global.js, global.css)
* @param absSrcPath
* @param files default load global files
*/
const getGlobalFiles = ({ absSrcPath, files }) => {
return files.map((file) => (0, path_1.join)(absSrcPath || '', file)).filter((file) => (0, fs_1.existsSync)(file));
};
exports.getGlobalFiles = getGlobalFiles;
const isDynamicRoute = (path) => { var _a, _b; return !!((_b = (_a = path === null || path === void 0 ? void 0 : path.split('/')) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, (snippet) => snippet.startsWith(':'))); };
exports.isDynamicRoute = isDynamicRoute;
/**
* judge whether ts or tsx file exclude d.ts
* @param path
*/
const isTSFile = (path) => {
return typeof path === 'string' && !/\.d\.ts$/.test(path) && /\.(ts|tsx)$/.test(path);
};
exports.isTSFile = isTSFile;