Skip to content

Commit

Permalink
Merge pull request #137 from whalemare/hotfix/dynamic-read
Browse files Browse the repository at this point in the history
Replace static "require" to dynamic "read"
  • Loading branch information
bcomnes authored Sep 20, 2021
2 parents e6117ba + bd36fd8 commit 6920478
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/lib/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const exec = require('shelljs').exec
const parseRepo = require('github-url-to-object')

function getDefaults (workPath, isEnterprise, callback) {
const pkg = require(path.resolve(workPath, 'package.json'))
const pkg = readJson(path.resolve(workPath, 'package.json'))
const lernaPath = path.resolve(workPath, 'lerna.json')

if (!Object.hasOwnProperty.call(pkg, 'repository')) {
Expand Down Expand Up @@ -49,7 +49,7 @@ function getDefaults (workPath, isEnterprise, callback) {
let lerna = {}
let errStr
if (fs.existsSync(lernaPath)) {
lerna = require(lernaPath) /* || {} */ // 👈 though I prefer this expression
lerna = readJson(lernaPath) /* || {} */ // 👈 though I prefer this expression
if (log.version !== lerna.version) {
errStr = 'CHANGELOG.md out of sync with lerna.json '
errStr += '(' + (log.version || log.title) + ' !== ' + lerna.version + ')'
Expand Down Expand Up @@ -87,5 +87,9 @@ function getTargetCommitish () {
return 'master'
}

function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath))
}

module.exports = getDefaults
module.exports.getTargetCommitish = getTargetCommitish

0 comments on commit 6920478

Please sign in to comment.