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 | 2x 2x 2x 2x 2x 2x 2x 2x 6x 4x 2x 2x 1x 2x 2x | #!/usr/bin/env node // @ts-check const { merge } = require('lodash'), process = require('process'), fs = require('fs'), { createCommand } = require('commander'), yaml = require('js-yaml'), pass = require('./pass'); const schema = yaml.DEFAULT_SCHEMA.extend( [ pass.PasswordType, pass.PasswordMapType ]); /** * @param {string} data * @return {string} */ function preload(data) { return dump(load(data)); } /** * @param {any} data * @param {any} [options] * @return any */ function load(data, options) { return yaml.load(data, merge({ schema }, options)); } /** * @param {any} data * @param {any} [options] * @return string */ function dump(data, options) { return yaml.dump(data, merge({ schema }, options)); } /** * @param {string} file * @param {any} [options] */ function tryLoadFile(file, options) { try { return load(fs.readFileSync(file).toString(), options); } catch { return undefined; } } Iif (require.main === module) { const args = createCommand('yaml-prepare') .argument('<file>', 'file to preprocess') .option('--no-pass', 'do not resolve password tags') .parse(process.argv); const opts = args.opts(); process.env.NO_PASS = opts.pass ? '' : '1'; process.on('unhandledRejection', function(reason) { console.warn(reason); process.exitCode = 1; }); console.log(preload(fs.readFileSync(args.processedArgs[0]).toString())); } else { module.exports = { preload, load, dump, schema, pass, tryLoadFile }; } |