Handle case when npm would return an error code (#3340)

This commit is contained in:
Alexandru Dima 2022-09-29 14:53:09 +02:00 committed by GitHub
parent 35eb0efbc0
commit 9d4574b10b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -90,10 +90,14 @@ function npmGetLatestVersion(packageName) {
* @returns {boolean} * @returns {boolean}
*/ */
function npmExists(packageName, version) { function npmExists(packageName, version) {
const output = cp.execSync(`npm show ${packageName}@${version} version`).toString(); try {
const result = output.split(/\r\n|\r|\n/g)[0]; const output = cp.execSync(`npm show ${packageName}@${version} version`).toString();
if (result.trim().length === 0) { const result = output.split(/\r\n|\r|\n/g)[0];
if (result.trim().length === 0) {
return false;
}
return true;
} catch (err) {
return false; return false;
} }
return true;
} }

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "monaco-editor", "name": "monaco-editor",
"version": "0.33.0", "version": "0.34.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "monaco-editor", "name": "monaco-editor",
"version": "0.33.0", "version": "0.34.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {