1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const config_1 = require("../models/config");
|
4 | const SilentError = require('silent-error');
|
5 | const Command = require('../ember-cli/lib/models/command');
|
6 | const GetCommand = Command.extend({
|
7 | name: 'get',
|
8 | description: 'Get a value from the configuration.',
|
9 | works: 'everywhere',
|
10 | availableOptions: [
|
11 | {
|
12 | name: 'global',
|
13 | type: Boolean,
|
14 | 'default': false,
|
15 | description: 'Get the value in the global configuration (in your home directory).'
|
16 | }
|
17 | ],
|
18 | run: function (commandOptions, rawArgs) {
|
19 | return new Promise(resolve => {
|
20 | const config = commandOptions.global ? config_1.CliConfig.fromGlobal() : config_1.CliConfig.fromProject();
|
21 | if (config === null) {
|
22 | throw new SilentError('No config found. If you want to use global configuration, '
|
23 | + 'you need the --global argument.');
|
24 | }
|
25 | const value = config.get(rawArgs[0]);
|
26 | if (value === null || value === undefined) {
|
27 | throw new SilentError('Value cannot be found.');
|
28 | }
|
29 | else if (typeof value == 'object') {
|
30 | console.log(JSON.stringify(value));
|
31 | }
|
32 | else {
|
33 | console.log(value);
|
34 | }
|
35 | resolve();
|
36 | });
|
37 | }
|
38 | });
|
39 | exports.default = GetCommand;
|
40 |
|
\ | No newline at end of file |