INNER CODE UNIT · JavaScript
collectionNames
open-source-labs/Swell · main.js:368
const collectionNames = args.map((obj) => obj.name);
fs.readFile(filepath, 'utf-8', (err, data) => {
if (err) {
alert('An error ocurred reading the file :', err.message);
return;
}
// parse data, will throw error if not parsable
let parsed;
// parsed.name already exists
try {
parsed = JSON.parse(data);
} catch {
options.message = 'Invalid File Structure';
options.detail = 'Please use a JSON object';
dialog.showMessageBox(null, options);
return;
}