Skip to content

Commit

Permalink
Enable twilio or first available profile after download
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Dec 27, 2024
1 parent 6878622 commit 3e5fc02
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cmd/esim.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ module.exports = class ESimCommands extends CLICommandBase {
await processOutput('No profile found on the device to enable');
return;
}

const enableResp = await this._enableProfile(port, iccidToEnable);
provisionOutputLogs.push(enableResp);
if (enableResp.status === 'failed') {
Expand Down Expand Up @@ -633,8 +634,9 @@ module.exports = class ESimCommands extends CLICommandBase {
const enableProfileCmd = `${this.lpa} enable ${iccid} --serial=${port}`;
const enableProfileResp = await execa(this.lpa, ['enable', `${iccid}`, `--serial=${port}`]);
res.details.rawLogs.push(enableProfileResp.stdout);
res.status = enableProfileResp.stdout.includes('Profile enabled successfully') ? 'success' : 'failed';
res.status = enableProfileResp.stdout.includes('Profile successfully enabled') ? 'success' : 'failed';
res.details.command = enableProfileCmd;
return res;
}

async _verifyIccidEnaled(port, iccid) {
Expand All @@ -649,7 +651,7 @@ module.exports = class ESimCommands extends CLICommandBase {
};

const profilesOnDeviceAfterEnable = await this._listProfiles(port);
const iccidString = profilesOnDeviceAfterEnable.some((line) => line.includes(iccid));
const iccidString = profilesOnDeviceAfterEnable.find((line) => line.includes(iccid));
if (iccidString) {
// check that you see the string 'enabled'
if (iccidString.includes('enabled')) {
Expand All @@ -659,7 +661,7 @@ module.exports = class ESimCommands extends CLICommandBase {
res.details.rawLogs.push(`ICCID ${iccid} not enabled`);
}
}
res.rawLogs.push(...profilesOnDeviceAfterEnable);
res.details.rawLogs.push(...profilesOnDeviceAfterEnable);
return res;
}

Expand Down

0 comments on commit 3e5fc02

Please sign in to comment.