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

box / boxcli / 4025218550

pending completion
4025218550

Pull #456

github

GitHub
Merge 5e271050e into 34aff89ac
Pull Request #456: fix: Fix unit tests

1081 of 1391 branches covered (77.71%)

Branch coverage included in aggregate %.

3965 of 4452 relevant lines covered (89.06%)

483.08 hits per line

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

25.0
/src/commands/configure/environments/delete.js
1
'use strict';
2

3
const BoxCommand = require('../../../box-command');
12✔
4
const BoxCLIError = require('../../../cli-error');
12✔
5
const inquirer = require('inquirer');
12✔
6

7
class EnvironmentsDeleteCommand extends BoxCommand {
8
        async run() {
9
                const { flags, args } = this.parse(EnvironmentsDeleteCommand);
×
10
                let environmentsObj = await this.getEnvironments();
×
11
                let name = args.name;
×
12

13
                if (!name) {
×
14
                        const choices = Object.keys(environmentsObj.environments);
×
15
                        if (choices.length === 0) {
×
16
                                throw new BoxCLIError('No environments to delete');
×
17
                        }
18
                        let answers = await inquirer.prompt([
×
19
                                {
20
                                        type: 'list',
21
                                        name: 'environment',
22
                                        message: 'Which environment?',
23
                                        choices: Object.keys(environmentsObj.environments),
24
                                }
25
                        ]);
26
                        name = answers.environment;
×
27
                }
28

29
                if (environmentsObj.environments.hasOwnProperty(name)) {
×
30
                        delete environmentsObj.environments[name];
×
31
                        if (environmentsObj.default === name) {
×
32
                                environmentsObj.default = '';
×
33
                        }
34
                        await this.updateEnvironments(environmentsObj);
×
35
                        this.info(`The ${name} environment was deleted`);
×
36
                } else {
37
                        this.error(`The ${name} environment does not exist`);
×
38
                }
39
        }
40
}
41

42
// @NOTE: This command does not require a client to be set up
43
EnvironmentsDeleteCommand.noClient = true;
12✔
44

45
EnvironmentsDeleteCommand.description = 'Delete a Box environment';
12✔
46

47
EnvironmentsDeleteCommand.flags = {
12✔
48
        ...BoxCommand.minFlags,
49
};
50

51
EnvironmentsDeleteCommand.args = [
12✔
52
        {
53
                name: 'name',
54
                required: false,
55
                hidden: false,
56
                description: 'Name of the environment'
57
        }
58
];
59

60
module.exports = EnvironmentsDeleteCommand;
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