How to use the @imgcook/cli-utils.downloadImg function in @imgcook/cli-utils

To help you get started, we’ve selected a few @imgcook/cli-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imgcook / imgcook-cli / packages / @imgcook / cli-loader-images / index.js View on Github external
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(

@imgcook/cli-utils

imgcook cli utils

MIT
Latest version published 3 years ago

Package Health Score

43 / 100
Full package analysis

Similar packages