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

box / boxcli / 10810816048

11 Sep 2024 11:36AM CUT coverage: 86.569% (-0.05%) from 86.616%
10810816048

Pull #542

github

web-flow
Merge a647aad97 into 0ed1618f5
Pull Request #542: docs: Add examples to file/folder metadata commands

1191 of 1536 branches covered (77.54%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 4 files covered. (100.0%)

1 existing line in 1 file now uncovered.

4281 of 4785 relevant lines covered (89.47%)

310.32 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');
8✔
4
const BoxCLIError = require('../../../cli-error');
8✔
5
const inquirer = require('inquirer');
8✔
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;
8✔
44

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

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

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

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