-
Notifications
You must be signed in to change notification settings - Fork 1
/
switch.js
35 lines (29 loc) · 1 KB
/
switch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { Command, flags } = require('@oclif/command');
const isSalesforceProject = require('../helpers/context-validation');
const { openOrg } = require('../helpers/scratch-org');
const { listOrgs } = require('../helpers/scratch-org-list');
const { setDefault } = require('../helpers/scratch-config');
class SwitchCommand extends Command {
async run() {
const { flags } = this.parse(SwitchCommand);
const isProject = isSalesforceProject();
if (!isProject) {
this.log('This folder is not a salesforce solution, cannot switch the scratch orgs.');
if (!flags.open) {
return;
}
}
const { username } = await listOrgs('Choose Scratch Org:');
if (isProject) {
await setDefault(username);
}
if (flags.open) {
await openOrg(username);
}
}
}
SwitchCommand.description = 'Change the default scratch org';
SwitchCommand.flags = {
open: flags.boolean({ char: 'o', description: 'Open the scratch org in the browser' })
};
module.exports = SwitchCommand;