lib/utils/yamlAstParser.js/addNewArrayItem
const addNewArrayItem = (ymlFile, pathInYml, newValue) =>
  fs.readFileAsync(ymlFile, 'utf8').then(yamlContent => {
    const rawAstObject = yaml.load(yamlContent);
    const astObject = parseAST(rawAstObject);
    const plainObject = constructPlainObject(rawAstObject);
    const pathInYmlArray = pathInYml.split('.');

    let currentNode = plainObject;
    for (let i = 0; i < pathInYmlArray.length - 1; i++) {
      const propertyName = pathInYmlArray[i];
      const property = currentNode[propertyName];
      if (_.isUndefined(property) || _.isObject(property)) {
        currentNode[propertyName] = property || {};
        currentNode = currentNode[propertyName];
      } else {
        throw new Error(`${property} can only be undefined or an object!`);
      }
    }

    const arrayPropertyName = _.last(pathInYmlArray);
    let arrayProperty = currentNode[arrayPropertyName];
    if (_.isUndefined(arrayProperty) || _.isArray(arrayProperty)) {
      arrayProperty = arrayProperty || [];
    } else {
      throw new Error(`${arrayProperty} can only be undefined or an array!`);
    }
    currentNode[arrayPropertyName] = _.union(arrayProperty, [newValue]);

    const branchToReplaceName = _.head(pathInYmlArray);
    const newObject = {};
    newObject[branchToReplaceName] = plainObject[branchToReplaceName];
    const newText = yaml.dump(newObject);
    if (astObject[branchToReplaceName]) {
      const beginning = yamlContent.substring(
        0,
        astObject[branchToReplaceName].parent.key.startPosition
      );
      const end = yamlContent.substring(
        astObject[branchToReplaceName].endPosition,
        yamlContent.length
      );
      return fs.writeFileAsync(ymlFile, `${beginning}${newText}${end}`);
    }
    return fs.writeFileAsync(ymlFile, `${yamlContent}${os.EOL}${newText}`);
  });