lib/utils/io.js
function mutateJsonFile(targetPath, source, mutator) {
  if (!mutator) {
    mutator = source;
    source = null;
  }
  let sourceConfig = source;
  try {
    // console.log('targetPath', targetPath);

    let targetConfig = readJson(targetPath);

    // console.log('source', source);
    if (typeof source === 'string') {
      sourceConfig = readJson(source);
    }
    // console.log('sourceConfig', targetPath, sourceConfig)
    sourceConfig = sourceConfig ? sourceConfig : targetConfig;

    let newConfig = mutator(targetConfig, sourceConfig);

    writeJson(targetPath, newConfig, {spaces: 2});

  } catch (e) {
    log.error('Error: operating on aurelia.json. Reverting to previous version ;{}', e);
    writeJson(targetPath, sourceConfig, {spaces: 2});
  }
}
function mutateJsonFile(targetPath, source, mutator) {
  if (!mutator) {
    mutator = source;
    source = null;
  }
  let sourceConfig = source;
  try {
    // console.log('targetPath', targetPath);

    let targetConfig = readJson(targetPath);

    // console.log('source', source);
    if (typeof source === 'string') {
      sourceConfig = readJson(source);
    }
    // console.log('sourceConfig', targetPath, sourceConfig)
    sourceConfig = sourceConfig ? sourceConfig : targetConfig;

    let newConfig = mutator(targetConfig, sourceConfig);

    writeJson(targetPath, newConfig, {spaces: 2});

  } catch (e) {
    log.error('Error: operating on aurelia.json. Reverting to previous version ;{}', e);
    writeJson(targetPath, sourceConfig, {spaces: 2});
  }
}
function mutateJsonFile ( targetPath , source , mutator ) { if ( ! mutator ) { mutator = source ; source = null ; } let sourceConfig = source ; try { // console.log('targetPath', targetPath); let targetConfig = readJson ( targetPath ) ; // console.log('source', source); if ( typeof source === 'string' ) { sourceConfig = readJson ( source ) ; } // console.log('sourceConfig', targetPath, sourceConfig) sourceConfig = sourceConfig ? sourceConfig : targetConfig ; let newConfig = mutator ( targetConfig , sourceConfig ) ; writeJson ( targetPath , newConfig , { spaces : 2 } ) ; } catch ( e ) { log . error ( 'Error: operating on aurelia.json. Reverting to previous version ;{}' , e ) ; writeJson ( targetPath , sourceConfig , { spaces : 2 } ) ; } }
source must be a filePath to a json file or an Object
source must be a filePath to a json file or an Object