Socket
Socket
Sign inDemoInstall

@imgcook/cli-loader-images

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imgcook/cli-loader-images - npm Package Compare versions

Comparing version 0.0.2-alpha.2 to 0.0.2-alpha.4

CHANGELOG.md

48

index.js

@@ -35,2 +35,8 @@ const fs = require('fs');

const imgPath = `${filePath}/images`;
let imgObj = [];
const imgrc = `${imgPath}/.imgrc`;
if (fs.existsSync(imgrc)) {
let imgConfig = fs.readFileSync(imgrc, 'utf8');
imgObj = JSON.parse(imgConfig) || [];
}
for (let idx = 0; idx < imgArr.length; idx++) {

@@ -44,15 +50,39 @@ if (!fs.existsSync(imgPath)) {

const imgPathItem = `${imgPath}/${imgName}`;
await downloadImg(imgArr[idx], imgPathItem);
let curImgObj = {};
for (const item of imgObj) {
if (item.imgUrl === imgArr[idx]) {
curImgObj = item;
}
}
const reg = new RegExp(imgArr[idx], 'g');
if (option.config && option.config.uploadUrl !== '') {
const udata = await uploadData(
imgPathItem,
`imgcook-cli/${temporaryImages}/`,
option.config
);
fileValue = fileValue.replace(reg, udata.url);
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 {
fileValue = fileValue.replace(reg, `./images/${imgName}`);
}
imgObj.push({
newImgUrl,
imgUrl: imgArr[idx],
imgPath: `./images/${imgName}`
});
} else {
fileValue = fileValue.replace(reg, `./images/${imgName}`);
if (option.config && option.config.uploadUrl !== '') {
fileValue = fileValue.replace(reg, curImgObj.newImgUrl);
} else {
fileValue = fileValue.replace(reg, curImgObj.imgPath);
}
}
}
if (imgObj.length > 0) {
fs.writeFileSync(imgrc, JSON.stringify(imgObj), 'utf8');
}
}

@@ -59,0 +89,0 @@ return fileValue;

4

package.json
{
"name": "@imgcook/cli-loader-images",
"version": "0.0.2-alpha.2",
"version": "0.0.2-alpha.4",
"description": "",

@@ -35,3 +35,3 @@ "main": "index.js",

},
"gitHead": "9d1c2f9ab77122908ef8247198fbf802cba8ba05"
"gitHead": "5413f8e186ce00734847a4044545f54d7c2bf48e"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc