@changesets/cli
Advanced tools
Comparing version 2.9.1 to 2.9.2
# @changesets/cli | ||
## 2.9.2 | ||
### Patch Changes | ||
- [`213de26`](https://github.com/atlassian/changesets/commit/213de26502c702b9e25ac3f4a04ea8e9099a5185) [#409](https://github.com/atlassian/changesets/pull/409) Thanks [@Andarist](https://github.com/Andarist)! - Add logs for failed `JSON.parse` calls. | ||
## 2.9.1 | ||
@@ -4,0 +10,0 @@ |
@@ -478,2 +478,14 @@ 'use strict'; | ||
function jsonParse(input) { | ||
try { | ||
return JSON.parse(input); | ||
} catch (err) { | ||
if (err instanceof SyntaxError) { | ||
console.error("error parsing json:", input); | ||
} | ||
throw err; | ||
} | ||
} | ||
function getCorrectRegistry() { | ||
@@ -499,3 +511,3 @@ let registry = process.env.npm_config_registry === "https://registry.yarnpkg.com" ? undefined : process.env.npm_config_registry; | ||
}); | ||
let json = JSON.parse(result.stdout.toString()); | ||
let json = jsonParse(result.stdout.toString()); | ||
@@ -523,3 +535,3 @@ if (json.error || !json.tfa || !json.tfa.mode) { | ||
}); | ||
return JSON.parse(result.stdout.toString()); | ||
return jsonParse(result.stdout.toString()); | ||
}); | ||
@@ -594,3 +606,3 @@ } | ||
let json = JSON.parse(stdout.toString().replace(/[^{]*/, "")); | ||
let json = jsonParse(stdout.toString().replace(/[^{]*/, "")); | ||
@@ -597,0 +609,0 @@ if (json.error) { |
@@ -305,2 +305,11 @@ "use strict"; | ||
function jsonParse(input) { | ||
try { | ||
return JSON.parse(input); | ||
} catch (err) { | ||
throw err instanceof SyntaxError && console.error("error parsing json:", input), | ||
err; | ||
} | ||
} | ||
function getCorrectRegistry() { | ||
@@ -319,5 +328,5 @@ return "https://registry.yarnpkg.com" === process.env.npm_config_registry ? void 0 : process.env.npm_config_registry; | ||
}; | ||
let result = await spawn("npm", [ "profile", "get", "--json" ], { | ||
let json = jsonParse((await spawn("npm", [ "profile", "get", "--json" ], { | ||
env: Object.assign({}, process.env, envOverride) | ||
}), json = JSON.parse(result.stdout.toString()); | ||
})).stdout.toString()); | ||
return !(json.error || !json.tfa || !json.tfa.mode) && "auth-and-writes" === json.tfa.mode; | ||
@@ -332,6 +341,5 @@ } | ||
}; | ||
let result = await spawn("npm", [ "info", pkgName, "--json" ], { | ||
return jsonParse((await spawn("npm", [ "info", pkgName, "--json" ], { | ||
env: Object.assign({}, process.env, envOverride) | ||
}); | ||
return JSON.parse(result.stdout.toString()); | ||
})).stdout.toString()); | ||
}); | ||
@@ -375,3 +383,3 @@ } | ||
env: Object.assign({}, process.env, envOverride) | ||
}), json = JSON.parse(stdout.toString().replace(/[^{]*/, "")); | ||
}), json = jsonParse(stdout.toString().replace(/[^{]*/, "")); | ||
return json.error ? ("EOTP" === json.error.code || "E401" === json.error.code && json.error.detail.includes("--otp=<code>")) && !isCI ? (null !== twoFactorState.token && (twoFactorState.token = null), | ||
@@ -378,0 +386,0 @@ twoFactorState.isRequired = Promise.resolve(!0), internalPublish(pkgName, opts, twoFactorState)) : (logger.error(`an error occurred while publishing ${pkgName}: ${json.error.code}`, json.error.summary, json.error.detail ? "\n" + json.error.detail : ""), |
@@ -474,2 +474,14 @@ import meow from 'meow'; | ||
function jsonParse(input) { | ||
try { | ||
return JSON.parse(input); | ||
} catch (err) { | ||
if (err instanceof SyntaxError) { | ||
console.error("error parsing json:", input); | ||
} | ||
throw err; | ||
} | ||
} | ||
function getCorrectRegistry() { | ||
@@ -495,3 +507,3 @@ let registry = process.env.npm_config_registry === "https://registry.yarnpkg.com" ? undefined : process.env.npm_config_registry; | ||
}); | ||
let json = JSON.parse(result.stdout.toString()); | ||
let json = jsonParse(result.stdout.toString()); | ||
@@ -519,3 +531,3 @@ if (json.error || !json.tfa || !json.tfa.mode) { | ||
}); | ||
return JSON.parse(result.stdout.toString()); | ||
return jsonParse(result.stdout.toString()); | ||
}); | ||
@@ -590,3 +602,3 @@ } | ||
let json = JSON.parse(stdout.toString().replace(/[^{]*/, "")); | ||
let json = jsonParse(stdout.toString().replace(/[^{]*/, "")); | ||
@@ -593,0 +605,0 @@ if (json.error) { |
{ | ||
"name": "@changesets/cli", | ||
"version": "2.9.1", | ||
"version": "2.9.2", | ||
"description": "Organise your package versioning and publishing to make both contributors and maintainers happy", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186213
2922