MCPcopy Create free account
hub / github.com/commitizen/cz-cli / getParsedJsonFromFile

Function getParsedJsonFromFile

src/common/util.js:14–21  ·  view source on GitHub ↗

* Gets the parsed contents of a json file

(filePath, fileName, encoding = 'utf8')

Source from the content-addressed store, hash-verified

12 * Gets the parsed contents of a json file
13 */
14function getParsedJsonFromFile (filePath, fileName, encoding = 'utf8') {
15 try {
16 var packageJsonContents = fs.readFileSync(path.join(filePath, fileName), encoding);
17 return JSON.parse(packageJsonContents);
18 } catch (e) {
19 console.error(e);
20 }
21}
22
23/**
24 * A helper method for getting the contents of package.json at a given path

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected