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

gturi / nca / 8277672099

14 Mar 2024 08:32AM UTC coverage: 86.091% (+0.1%) from 85.979%
8277672099

push

github

web-flow
Merge pull request #213 from gturi/feature/nca-alias-command

Feature/nca alias command

221 of 316 branches covered (69.94%)

Branch coverage included in aggregate %.

598 of 661 new or added lines in 62 files covered. (90.47%)

1 existing line in 1 file now uncovered.

1116 of 1237 relevant lines covered (90.22%)

1211.08 hits per line

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

42.42
/src/command/path/add-path-command.ts
1
import yargs from "yargs";
2
import { OptionParam } from '../../model/api/option-param';
3
import { OptionParamType } from '../../model/api/option-param-type';
161✔
4
import { PositionalArgument } from '../../model/api/positional-argument';
5
import { PositionalArgumentType } from '../../model/api/positional-argument-type';
161✔
6
import { ConfigLoader } from '../../loader/config-loader';
161✔
7
import { ConfigSaver } from '../../util/config-saver';
161✔
8
import { AnyObj } from "../../util/custom-types";
9
import { YargsUtils } from '../../util/yargs-utils';
161✔
10
import { NcaConfig } from "../../config/nca-config";
161✔
11
import { NcaCommandTemplate } from "../../model/internal/nca-command-template";
161✔
12

13
export class AddPathCommand extends NcaCommandTemplate {
161✔
14

15
  override getCommandName(): string {
16
    return YargsUtils.getCommand('add', this.getPositionalArguments());
161✔
17
  }
18

19
  override getCommandDescription(): string {
20
    return 'include path into configuration file';
161✔
21
  }
22

23
  override getPositionalArguments(): PositionalArgument[] {
24
    const positionalArgument: PositionalArgument = {
322✔
25
      name: 'configPath',
26
      description: 'config path to add',
27
      type: PositionalArgumentType.String,
28
      required: true
29
    }
30
    return [positionalArgument];
322✔
31
  }
32

33
  override getOptionParams(): OptionParam[] {
34
    const optionParam: OptionParam = {
161✔
35
      name: 'f',
36
      alternativeName: 'file',
37
      description: 'configuration path to that will include the new config',
38
      optionType: OptionParamType.String,
39
      defaultValue: NcaConfig.getMainConfigFilePath()
40
    }
41
    return [optionParam];
161✔
42
  }
43

44
  override getHandler<T = AnyObj>(args: yargs.ArgumentsCamelCase<T>): void {
45
    const configPath = args.f as string;
×
46
    const configPathToAdd = args.configPath as string;
×
47

48
    const configLoader = new ConfigLoader();
×
49
    const config = configLoader.loadConfig(configPath);
×
50

NEW
51
    if (config.includePaths?.includes(configPathToAdd)) {
×
NEW
52
      console.log('The path is already included');
×
NEW
53
      return;
×
54
    }
55

56
    if (config.includePaths) {
×
57
      config.includePaths.push(configPathToAdd);
×
58
    } else {
59
      config.includePaths = [configPathToAdd];
×
60
    }
61

62
    ConfigSaver.save(configPath, config);
×
63
  }
64
}
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