From 9b07159c56d71dd95d8282a9715525b588cc9b22 Mon Sep 17 00:00:00 2001 From: keeramis Date: Tue, 19 Nov 2024 14:02:14 -0800 Subject: [PATCH] Fix error msgs --- src/cmd/esim.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/cmd/esim.js b/src/cmd/esim.js index fceee2bf0..f3013aa77 100644 --- a/src/cmd/esim.js +++ b/src/cmd/esim.js @@ -35,11 +35,11 @@ module.exports = class eSimCommands extends CLICommandBase { console.log(`${os.EOL}Provisioning device ${device.deviceId} with platform ${platform}`); // Flash firmware and retrieve EID - await this._flashATPassThroughFirmware(device, platform, port); + // await this._flashATPassThroughFirmware(device, platform, port); const eid = await this._getEid(port); console.log(`${os.EOL}EID: ${eid}`); - await this._checkForExistingProfiles(port); + // await this._checkForExistingProfiles(port); // Parse the JSON to get EID and profiles const input = fs.readFileSync(this.inputJson); @@ -89,6 +89,7 @@ module.exports = class eSimCommands extends CLICommandBase { provider: profile.provider, iccid, time: timeTaken, + success: true, output, }; @@ -98,6 +99,7 @@ module.exports = class eSimCommands extends CLICommandBase { EID: eid, provider: profile.provider, iccid, + success: false, time: timeTaken, output: err.message, }; @@ -212,25 +214,20 @@ module.exports = class eSimCommands extends CLICommandBase { async _checkForExistingProfiles(port) { console.log(`${os.EOL}Checking for existing profiles...`); - try { - const resProfiles = await execa(this.lpa, ['listProfiles', `--serial=${port}`]); - const profilesOutput = resProfiles.stdout; - - // Extract lines matching the profile format - const profilesList = profilesOutput - .split('\n') - .filter((line) => line.match(/^\d+:\[\w+,\s(?:enabled|disabled),\s?\]$/)); + const resProfiles = await execa(this.lpa, ['listProfiles', `--serial=${port}`]); + const profilesOutput = resProfiles.stdout; - if (profilesList.length > 0) { - console.error(`${os.EOL}Profile(s) already exist:`, profilesList); - throw new Error('Profile(s) already exist. Device bucket is not clean.'); - } + // Extract lines matching the profile format + const profilesList = profilesOutput + .split('\n') + .filter((line) => line.match(/^\d+:\[\w+,\s(?:enabled|disabled),\s?\]$/)); - console.log(`${os.EOL}No existing profiles found`); - } catch (error) { - console.error(`${os.EOL}Failed to check for existing profiles: ${error.message}`); - throw error; + if (profilesList.length > 0) { + console.error(`${os.EOL}Profile(s) already exist:`, profilesList); + throw new Error('Profile(s) already exist. Troubleshoot manually.'); } + + console.log(`${os.EOL}No existing profiles found`); } _addToJson(jsonFile, data) {