1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/janpoem-webpack-miniprogram-plugin

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
utils.js 1.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Jan Отправлено 16.05.2019 04:54 64b85a7
const fs = require('fs');
const pathUtil = require('path');
const colors = require('ansi-colors');
const _ = require('lodash');
const readJsonSync = (file) => {
try {
const data = fs.readFileSync(file);
return JSON.parse(data);
} catch (e) {
}
return {};
};
const filterExts = (exts) => _.keys(exts).filter(ext => ext !== '' && !!exts[ext]);
const replaceDS = (path) => path.replace(/[\\/]+/g, '/');
const removeExt = (path) => {
const ext = pathUtil.extname(path);
if (ext !== '') {
const reg = new RegExp(`${ext}$`);
return path.replace(reg, '');
}
return path;
};
const filterExcludeItems = (items, excludes) => {
excludes = _.uniq(_.flattenDeep(excludes));
return items.filter(item => excludes.indexOf(item) < 0);
};
const warn = (msg) => {
return colors.yellowBright(msg);
};
const error = (msg) => {
return colors.bold.redBright(msg);
};
const highLight = (msg) => {
return colors.underline.cyan(msg);
};
const right = (msg) => {
return colors.bold.green(msg);
};
const filterMode = (mode) => {
switch (mode.toLowerCase()) {
case 'production' :
case 'prod' :
return 'production';
default:
return 'development';
}
};
module.exports = {
readJsonSync,
filterExts,
replaceDS,
removeExt,
filterExcludeItems,
warn, error, highLight, right,
filterMode
};

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/janpoem-webpack-miniprogram-plugin.git
git@api.gitlife.ru:oschina-mirror/janpoem-webpack-miniprogram-plugin.git
oschina-mirror
janpoem-webpack-miniprogram-plugin
janpoem-webpack-miniprogram-plugin
master