Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!fs.existsSync(imgPath)) {
fs.mkdirSync(imgPath);
}
let suffix = imgArr[idx].split('.');
suffix = suffix[suffix.length - 1];
const imgName = `img_${option.moduleData.id}_${index}_${idx}.${suffix}`;
const imgPathItem = `${imgPath}/${imgName}`;
let curImgObj = {};
for (const item of imgObj) {
if (item.imgUrl === imgArr[idx]) {
curImgObj = item;
}
}
const reg = new RegExp(imgArr[idx], 'g');
if (!curImgObj.imgPath) {
await downloadImg(imgArr[idx], imgPathItem);
let newImgUrl = '';
if (option.config && option.config.uploadUrl !== '') {
const udata = await uploadData(
imgPathItem,
`imgcook-cli/${temporaryImages}/`,
option.config
);
fileValue = fileValue.replace(reg, udata.url);
newImgUrl = udata.url;
} else if (
option.moduleData &&
option.moduleData.dsl === 'react-taobao-standard'
) {
// 如果在 react 标准下引用本地路径图片,使用 require 引用
const regex = new RegExp(`"${imgArr[idx]}"`, 'g');
fileValue = fileValue.replace(