picgo-plugin-gitee 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +8 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picgo-plugin-gitee",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "picgo uploader for gitee",
5
5
  "main": "src/index.js",
6
6
  "files": [
package/src/index.js CHANGED
@@ -188,7 +188,11 @@ module.exports = (ctx) => {
188
188
  };
189
189
  try {
190
190
  const response = await ctx.Request.request(opts);
191
- ctx.log.info("[删除操作]响应:" + response);
191
+ // 兼容 string / object 两种响应形态,避免日志打 "[object Object]"
192
+ ctx.log.info(
193
+ "[删除操作]响应:" +
194
+ (typeof response === "string" ? response : JSON.stringify(response))
195
+ );
192
196
  successNames.push(each.fileName || each.imgUrl);
193
197
  } catch (err) {
194
198
  ctx.log.info(
@@ -245,9 +249,10 @@ module.exports = (ctx) => {
245
249
  };
246
250
 
247
251
  let res = await ctx.Request.request(opts);
248
- let tmp = JSON.parse(res);
252
+ // 兼容 picgo-core(返回 JSON 字符串)和 picgo GUI(直接返回 parsed object)
253
+ let tmp = typeof res === "string" ? JSON.parse(res) : res;
249
254
 
250
- return tmp.sha;
255
+ return tmp && tmp.sha;
251
256
  };
252
257
 
253
258
  const formatConfigPath = function (userConfig) {