Read the latest published version from npm, do not rely on `package.json` (fixes #2800)

pull/2806/head
Alex Dima 2021-12-03 17:15:37 +01:00
parent b4f1ca62dd
commit 1f9655af22
No known key found for this signature in database
GPG Key ID: 39563C1504FDD0C9
1 changed files with 2 additions and 3 deletions

View File

@ -16,9 +16,8 @@ const { REPO_ROOT, removeDir, readFiles, writeFiles } = require('./utils');
/** @type {string} */ /** @type {string} */
const MONACO_EDITOR_VERSION = (() => { const MONACO_EDITOR_VERSION = (() => {
const packageJsonPath = path.join(REPO_ROOT, 'package.json'); const output = cp.execSync(`npm show monaco-editor version`).toString();
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()); const version = output.split(/\r\n|\r|\n/g)[0];
const version = packageJson.version;
if (!/\d+\.\d+\.\d+/.test(version)) { if (!/\d+\.\d+\.\d+/.test(version)) {
console.log('unrecognized package.json version: ' + version); console.log('unrecognized package.json version: ' + version);
process.exit(1); process.exit(1);