lib/util.js
function writeConfig(filePath, data, fileFormat) {
  if (!filePath || !data) {
    throw new Error('No file/data to save!');
  }

  const ext = rgxExt.exec(filePath) || [];
  const format = fileFormat || ext[1];

  if (format === 'yaml' || format === 'yml') {
    return writeFileSync(filePath, yaml.safeDump(data), { encoding: 'utf8' });
  }

  return outputJSONSync(filePath, data, { spaces: 2 });
}
function writeConfig(filePath, data, fileFormat) {
  if (!filePath || !data) {
    throw new Error('No file/data to save!');
  }

  const ext = rgxExt.exec(filePath) || [];
  const format = fileFormat || ext[1];

  if (format === 'yaml' || format === 'yml') {
    return writeFileSync(filePath, yaml.safeDump(data), { encoding: 'utf8' });
  }

  return outputJSONSync(filePath, data, { spaces: 2 });
}
function writeConfig ( filePath , data , fileFormat ) { if ( ! filePath || ! data ) { throw new Error ( 'No file/data to save!' ) ; } const ext = rgxExt . exec ( filePath ) || [ ] ; const format = fileFormat || ext [ 1 ] ; if ( format === 'yaml' || format === 'yml' ) { return writeFileSync ( filePath , yaml . safeDump ( data ) , { encoding : 'utf8' } ) ; } return outputJSONSync ( filePath , data , { spaces : 2 } ) ; }
Writes a given JSON object `data` to a `filePath` with the requested `format`.

@param  {String} filePath   The path where to write the file.
@param  {Object} data       The object to write into the file contents.
@param  {String} fileFormat One of "yaml", "yml", "json".
Writes a given JSON object data to a filePath with the requested format .