all files / lib/ reporter.js

100% Statements 11/11
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11
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                                      
const colors = require('colors');
const p      = require('path');
const yaml   = require('node-yaml');
 
/**
 * Write definitions YAML to console stdout.
 *
 * @param {Array} definitions: an array of definitions object
 * @param {Object} opts: unused, only here for signature consistency
 */
function _console(definitions, opts) {
  console.log(yaml.dump(definitions));
}
 
/**
 * Write definitions YAML to file.
 *
 * @param {Array} definitions: an array of definitions object
 * @param {Object} opts: optional
 *   - outFile: path to output file, relative to where the process runs
 */
function file(definitions, opts) {
  var outFile = p.join(process.cwd(), opts.outFile);
  console.log('Writing output file %s...'.cyan, outFile);
  yaml.writeSync(outFile, definitions);
}
 
exports.console = _console;
exports.file    = file;