Skip to content

Commit 31e7df4

Browse files
update sync function -- revelation! Let's refactor
1 parent 8562089 commit 31e7df4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/commands/token/sync.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ class SyncTokenGenerator extends TwilioClientCommand {
1111
this.showHeaders = true;
1212
}
1313

14-
validateSyncServiceSid() {
14+
validateSyncServiceSid(sid) {
1515
return (
16-
this.flags['sync-service-sid'].startsWith('IS') &&
17-
this.flags['sync-service-sid'].length === 34
16+
sid.startsWith('IS') &&
17+
sid.length === 34
1818
);
1919
}
2020

2121
async run() {
2222
await super.run();
2323

24+
const syncServiceSid = await this.flags['sync-service-sid'];
2425
const accessToken = createToken.call(this);
2526

26-
if (!this.validateSyncServiceSid()) {
27+
if (!this.validateSyncServiceSid(syncServiceSid)) {
2728
this.logger.error(
2829
'Invalid Sync Service SID, must look like ISxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
2930
);
3031
process.exit(1);
3132
}
3233

3334
let syncGrant = new Twilio.jwt.AccessToken.SyncGrant({
34-
serviceSid: this.flags['sync-service-sid'],
35+
serviceSid: syncServiceSid
3536
});
3637
accessToken.addGrant(syncGrant);
3738

0 commit comments

Comments
 (0)