Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

Alorel / personal-build-tools / 367

23 Oct 2018 - 20:45 coverage increased (+5.02%) to 78.602%
367

Pull #33

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
fix travis typecheck script
Pull Request #33: Build

374 of 617 branches covered (60.62%)

Branch coverage included in aggregate %.

288 of 325 new or added lines in 9 files covered. (88.62%)

178 existing lines in 29 files now uncovered.

1470 of 1729 relevant lines covered (85.02%)

38.24 hits per line

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

47.62
/src/fns/parseJointCfgForEncryption.ts
1
import {cloneDeep, forEach} from 'lodash';
2
import {Colour} from '../lib/Colour';
8×
3
import {Crypt} from '../lib/Crypt';
8×
4
import {PromptableConfig} from '../lib/PromptableConfig';
8×
5

8×
6
const enum Conf {
8×
7
  MAX_ATTEMPTS = 3
8
}
6×
9

6×
10
function setRegular(cfg: any, k: string, value: any): void {
11
  Object.defineProperty(cfg, k, {
UNCOV
12
    configurable: true,
!
13
    enumerable: true,
14
    value,
15
    writable: true
16
  });
17
}
18

19
function setVirtual(pcfg: PromptableConfig<any>, cfg: any, k: string, v: any): void {
UNCOV
20
  let attempt = 1;
!
UNCOV
21
  const colourFns = [<any>undefined, Colour.green, Colour.yellow, Colour.red];
!
UNCOV
22

!
23
  Object.defineProperty(cfg, k, {
24
    configurable: true,
25
    enumerable: true,
26
    get: function getter(): any {
!
UNCOV
27
      const pwd = pcfg.promptedEncryptionPassword();
!
UNCOV
28
      try {
!
UNCOV
29
        const decrypted = Crypt.decryptVar(v, pwd);
!
UNCOV
30
        setRegular(cfg, k, decrypted);
!
31
        attempt = 1;
!
32

33
        return decrypted;
34
      } catch (e) {
!
35
        const msg = [
36
          Colour.red(e.message),
37
          ` [${colourFns[attempt].call(Colour, attempt)}/`,
38
          `${Colour.red(Conf.MAX_ATTEMPTS.toString())}]\n`
39
        ].join('');
!
UNCOV
40
        process.stderr.write(msg);
Branches [[1, 0], [1, 1]] missed. !
UNCOV
41

!
UNCOV
42
        if (attempt++ < Conf.MAX_ATTEMPTS) {
!
UNCOV
43
          delete pcfg['data'].password;
!
44
          pcfg.promptedEncryptionPassword['cache'].clear();
45

UNCOV
46
          return getter();
!
47
        } else {
48
          process.exit(1);
49
        }
50
      }
UNCOV
51
    },
Branches [[2, 0]] missed. !
52
    set(v$: any) {
108×
53
      if (Crypt.isEncrypted(v$)) {
54
        setVirtual(pcfg, cfg, k, v$);
55
      } else {
108×
56
        setRegular(cfg, k, v$);
57
      }
58
    }
59
  });
60
}
61

110×
62
export function parseJointCfgForEncryption<T>(cfg: T): T {
22×
63
  cfg = cloneDeep(cfg);
2×
64
  const pcfg = new PromptableConfig(cfg);
Branches [[3, 0]] missed. 110×
65

2×
66
  forEach(<any>cfg, (v: any, k: string) => {
67
    if (Crypt.isEncrypted(v)) {
68
      setVirtual(pcfg, cfg, k, v);
2×
69
    }
70
  });
6×
71

72
  return cfg;
73
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2022 Coveralls, Inc