UNPKG

@sap/generator-cap-project

Version:

Creates a new SAP Cloud Application Programming Model project.

18 lines (17 loc) 495 B
export default function readJSON(filepath, defaults) { if (this.exists(filepath)) { try { const content = this.read(filepath); if (!content) { throw new Error(`${filepath} has no content`); } return JSON.parse(content); } catch (error) { throw new Error('Could not parse JSON in file: ' + filepath + '. Detail: ' + error.message); } } else { return defaults; } }