Skip to content

Commit

Permalink
fix(fs): re-read package.json from disk to make sure it is not stale
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Jun 30, 2021
1 parent 00a7dc1 commit 918d113
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const handler = async ({ force, name, cwd, lib }) => {
}

reporter.info('Creating package scripts...')
const pkg = require(paths.package)
const pkg = fs.readJsonSync(paths.package)
if (pkg.scripts && pkg.scripts.build && !force) {
reporter.warn(
'A script called "build" already exists, use --force to overwrite it'
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/parseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const parseConfig = paths => {
config = defaultsDeep(config, require(defaults))

if (fs.existsSync(paths.package)) {
const pkg = require(paths.package)
const pkg = fs.readJsonSync(paths.package)
config.name = config.name || pkg.name
config.version = config.version || pkg.version
config.author = config.author || parseAuthor(pkg.author)
Expand Down
3 changes: 2 additions & 1 deletion cli/src/lib/validatePackage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const fs = require('fs-extra')
const {
validatePackageExports,
} = require('./validators/validatePackageExports')
Expand All @@ -16,7 +17,7 @@ module.exports.validatePackage = async ({

let pkg
try {
pkg = require(paths.package)
pkg = fs.readJsonSync(paths.package)
} catch (e) {
reporter.error(`Failed to load package manifest at ${paths.package}`)
return false
Expand Down

0 comments on commit 918d113

Please sign in to comment.