* This function converts a single example file into a newer version and overwrite the old one. * * @param {*} exampleFile full path to file
(exampleFile)
| 11 | * @param {*} exampleFile full path to file |
| 12 | */ |
| 13 | function convertExample(exampleFile) { |
| 14 | console.warn(`Converting: ${exampleFile}`); |
| 15 | const document = fs.readFileSync(exampleFile, 'utf-8'); |
| 16 | const loadedDocument = jsYaml.load(document); |
| 17 | if(loadedDocument.asyncapi === undefined) { |
| 18 | //Probably encountered a common file (used in other files), ignore |
| 19 | console.error(`___________________________________________________________________________________ |
| 20 | !!!Manual change required!!! |
| 21 | |
| 22 | ${exampleFile} is a shared resource among other AsyncAPI documents, make sure to manually inspect this! |
| 23 | |
| 24 | ___________________________________________________________________________________`); |
| 25 | return; |
| 26 | } else if(loadedDocument.asyncapi === toVersion) { |
| 27 | console.warn(`${exampleFile} is already version ${toVersion}`); |
| 28 | return; |
| 29 | } |
| 30 | const convertedDocument = convert(document, toVersion, { }); |
| 31 | fs.writeFileSync(exampleFile, convertedDocument); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Convert all examples within a single directory and nested directories. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…