1 Star 1 Fork 0

zzzoucx/taro-dva-ts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
get-iconfont.js 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
kai 提交于 2019-10-30 16:09 . 升级taro
const fs = require('fs');
const request = require('request');
const newPath = process.argv[2];
if (!newPath) {
console.log('【Error】需要 http://at.alicdn.com/t/...后面这一串');
console.log('示例:node get-iconfont.js font_153770_kdb4omr364a');
process.exit(0);
}
const fontPath = 'http://at.alicdn.com/t/font_153770_qxdb439a27p';
const suffixs = ['.eot', '.woff', '.ttf', '.svg', '.css'];
const promise = (ele) => {
return new Promise((resolve, reject) => {
const downloadPath = `${fontPath}${ele}`;
const options = {
method: 'GET',
url: downloadPath,
headers: {
'cache-control': 'no-cache'
}
};
request(options, (error, response, body) => {
if (error) {
reject(`iconfont${ele}下载失败了`);
throw new Error(error);
}
if (ele === '.css') {
body = body.replace(/16px/, '50px');
fs.writeFileSync(`./src/static/iconfont/iconfont.scss`, body);
} else {
fs.writeFileSync(`./src/static/iconfont/iconfont${ele}`, body);
}
resolve(`iconfont${ele}下载更新成功`);
});
});
};
const promises = suffixs.map((ele) => {
return promise(ele);
});
Promise.all(promises).then((res) => {
console.log(res);
process.exit(0);
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zzzoucx/taro-dva-ts.git
git@gitee.com:zzzoucx/taro-dva-ts.git
zzzoucx
taro-dva-ts
taro-dva-ts
master

搜索帮助