Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 2x 2x 2x 2x 4x 4x 3x 3x 3x 3x 2x 2x 2x 2x 2x 1x 1x 4x 2x 1x 1x 3x 3x 2x | // @ts-check const { toString, trim, isNil, get } = require('lodash'), { execFileSync } = require('child_process'), process = require('process'), yaml = require('js-yaml'); class PasswordTagScalar { /** * @param {string} pass * @param {boolean} [resolve=!process.env.NO_PASS] */ constructor(pass, resolve = !process.env.NO_PASS) { this.pass = pass; this.resolve = resolve; } get() { return trim(toString(execFileSync('pass', [ this.pass ]))); } } class PasswordTagMapping { /** * @param {any} pass * @param {any} [options={}] * @param {boolean} [resolve=!process.env.NO_PASS] */ constructor(pass, options = {}, resolve = !process.env.NO_PASS) { this.pass = pass; this.resolve = resolve; this.options = options; } get() { const line = get(this.options, 'line'); const res = trim(toString(execFileSync('pass', [ this.pass ]))); Eif (!isNil(line)) { return get(res.split('\n'), [ line - 1 ], ''); } else { return res; } } } /** @type {yaml.Type<PasswordTagScalar>} */ const PasswordType = new yaml.Type('!pass', { kind: 'scalar', /** @param {PasswordTagScalar} pass */ // @ts-ignore represent(pass) { return pass.resolve ? pass.get() : pass.pass; }, multi: true, /** * @this {yaml.Type<PasswordTagScalar>} * @param {PasswordTagScalar} pass */ representName(pass) { return pass.resolve ? null : this.tag; }, instanceOf: PasswordTagScalar, construct(data) { return (!process.env.NO_PASS) ? (new PasswordTagScalar(data)).get() : (new PasswordTagScalar(data)); } }); const PasswordMapType = new yaml.Type('!pass', { kind: 'mapping', /** @param {PasswordTagMapping} pass */ represent(pass) { return pass.resolve ? pass.get() : pass.options; }, multi: true, /** * @this {yaml.Type<PasswordTagMapping>} * @param {PasswordTagMapping} pass */ representName(pass) { return pass.resolve ? null : this.tag; }, instanceOf: PasswordTagMapping, construct(data) { const name = get(data, 'name'); return (!process.env.NO_PASS) ? (new PasswordTagMapping(name, data)).get() : (new PasswordTagMapping(name, data)); } }); module.exports = { PasswordType, PasswordMapType, PasswordTagScalar, PasswordTagMapping }; |