代码拉取完成,页面将自动刷新
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);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。