• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / boxcli / 3757387352

pending completion
3757387352

Pull #443

github

GitHub
Merge bb359784e into 8779eecf2
Pull Request #443: chore: run tests on node 14, 16 and 18

1079 of 1389 branches covered (77.68%)

Branch coverage included in aggregate %.

3940 of 4426 relevant lines covered (89.02%)

483.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.0
/src/commands/configure/environments/switch-user.js
1
'use strict';
2

3
const BoxCommand = require('../../../box-command');
12✔
4
const { flags } = require('@oclif/command');
12✔
5
const chalk = require('chalk');
12✔
6

7
class EnvironmentsSwitchUserCommand extends BoxCommand {
8
        async run() {
9
                const { flags, args } = this.parse(EnvironmentsSwitchUserCommand);
×
10

11
                let environmentsObj = await this.getEnvironments();
×
12
                let environment = environmentsObj.environments[environmentsObj.default];
×
13

14
                if (flags.default && !args.userID) {
×
15
                        environment.useDefaultAsUser = false;
×
16
                } else if (args.userID && !flags.default) {
×
17
                        environment.useDefaultAsUser = true;
×
18
                        environment.defaultAsUserId = args.userID;
×
19
                } else {
20
                        throw new Error('Either a userID argument or --default flag must be passed, but not both');
×
21
                }
22

23
                await this.updateEnvironments(environmentsObj);
×
24
                this.info(chalk`{green User set to ${args.userID || 'default'}}`);
×
25
        }
26
}
27

28
// @NOTE: This command does not require a client to be set up
29
EnvironmentsSwitchUserCommand.noClient = true;
12✔
30

31
EnvironmentsSwitchUserCommand.description = 'Switch the default Box user to run commands as';
12✔
32

33
EnvironmentsSwitchUserCommand.flags = {
12✔
34
        ...BoxCommand.minFlags,
35
};
36

37
EnvironmentsSwitchUserCommand.args = [
12✔
38
        {
39
                name: 'userID',
40
                hidden: false,
41
                required: false,
42
                description: 'The user ID to switch to'
43
        }
44
];
45

46
EnvironmentsSwitchUserCommand.flags = {
12✔
47
        ...BoxCommand.flags,
48
        default: flags.boolean({
49
                description: 'Switch to the default user, i.e. the Service Account'
50
        }),
51
};
52

53
module.exports = EnvironmentsSwitchUserCommand;
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc