UNPKG

853 BJavaScriptView Raw
1/**
2 * 获取指定文件的相关信息
3 *
4 * @param {string} filePath
5 * @returns
6 *
7 * @memberOf Watch
8 */
9let getFileInfo = (filePath)=>{
10 const {path} = {
11 path:require('path')
12 };
13
14 let tempObj = {};
15 // extname = (()=>{
16 // let name = path.extname(filePath).toLowerCase();
17 // return filePath.toLocaleLowerCase().substr(-5) === '.d.ts' ? '.d.ts' : name;
18 // })();
19
20 tempObj.path = filePath;
21 tempObj.type = path.extname(filePath).toLowerCase(); // 文件扩展名,例如:".png"(.d.ts文件则不为.ts)
22 tempObj.name = path.basename(filePath,tempObj.type); // 文件名称不包含扩展名
23 tempObj.isPublic = tempObj.name.substr(0,1) === '_'; // 取文件名第一个字符,判断是否为公共文件
24 return tempObj;
25};
26
27module.exports = getFileInfo;
\No newline at end of file