UNPKG

652 BJavaScriptView Raw
1/**
2 * 判断是否为精灵图
3 *
4 * @param {string} filePath 图片路径
5 * @returns
6 *
7 * @memberOf Watch
8 */
9module.exports = (filePath)=>{
10 const {path,pathInfo} = {
11 path:require('path'),
12 pathInfo:require('./getPathInfo')
13 };
14
15 let fileType = path.extname(filePath).toLowerCase(), //文件类型
16 isSpriteDir = (()=>{
17 let adirNames = path.dirname(filePath).split(path.sep),
18 dirName = adirNames[adirNames.length - 1].toLowerCase();
19 return dirName.indexOf('_sprite') === 0;
20 })(),
21 isImg = fileType === '.png' || fileType === '.svg';
22
23 return isSpriteDir && isImg;
24};
\No newline at end of file