All checks were successful
Generate Release / validate_and_release (push) Successful in 5s
27 lines
766 B
JavaScript
27 lines
766 B
JavaScript
const fs = require('fs');
|
|
const yaml = require('yaml');
|
|
|
|
const inputFile = process.argv[2];
|
|
const outputFile = 'pis-objects.jsonl';
|
|
|
|
if (!inputFile) {
|
|
console.error('Please provide an input YAML file');
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
const fileContent = fs.readFileSync(inputFile, 'utf8');
|
|
const data = yaml.parse(fileContent);
|
|
|
|
if (!data || !data.pis || !Array.isArray(data.pis)) {
|
|
throw new Error('Invalid structure: Expected object with "pis" array.');
|
|
}
|
|
|
|
const jsonl = data.pis.map(item => JSON.stringify(item));
|
|
|
|
fs.writeFileSync(outputFile, jsonl.join('\n') + '\n');
|
|
console.log(`Successfully processed ${data.pis.length} items.`);
|
|
} catch (e) {
|
|
console.error("Conversion failed: ", e.message);
|
|
process.exit(1);
|
|
} |