Fixed the issue where command throws an error if strapi key is not in package.json

This commit is contained in:
ivanThePleasant 2022-03-24 20:42:16 +02:00
parent ce5ddb2868
commit d007218b96

View File

@ -9,7 +9,7 @@ const machineID = require('../utils/machine-id');
const readPackageJSON = async path => {
try {
const packageObj = await fse.readJson(path);
const uuid = packageObj.strapi.uuid;
const uuid = packageObj.strapi ? packageObj.strapi.uuid : null;
return [uuid, packageObj];
} catch (err) {
@ -52,7 +52,7 @@ module.exports = async function optOutTelemetry() {
const [uuid, packageObj] = await readPackageJSON(packageJSON);
if (packageObj.strapi.telemetryDisabled || !uuid) {
if ((packageObj.strapi && packageObj.strapi.telemetryDisabled) || !uuid) {
console.log(`${chalk.yellow('Warning:')} telemetry is already disabled`);
process.exit(0);
}