function convertExample(exampleFile) {
  console.warn(`Converting: ${exampleFile}`);
  const document = fs.readFileSync(exampleFile, 'utf-8');
  const loadedDocument = jsYaml.load(document);
  if(loadedDocument.asyncapi === undefined) {
    //Probably encountered a common file (used in other files), ignore
    console.error(`___________________________________________________________________________________
    !!!Manual change required!!! 

    ${exampleFile} is a shared resource among other AsyncAPI documents, make sure to manually inspect this!

___________________________________________________________________________________`);
    return;
  } else if(loadedDocument.asyncapi === toVersion) {
    console.warn(`${exampleFile} is already version ${toVersion}`);
    return;
  }
  const convertedDocument = convert(document, toVersion, { });
  fs.writeFileSync(exampleFile, convertedDocument);
}
This function converts a single example file into a newer version and overwrite the old one.

@param {*} exampleFile full path to file