Skip to content

Commit

Permalink
fix: issue npm#7892 prevent package-lock.json creation without packag…
Browse files Browse the repository at this point in the history
…e.json
  • Loading branch information
Kyle-Ignis committed Dec 5, 2024
1 parent 2af31dd commit 01f92e0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions workspaces/arborist/bin/reify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fs = require('node:fs')
const path = require('node:path')
const Arborist = require('../')

const printTree = require('./lib/print-tree.js')
Expand Down Expand Up @@ -31,6 +33,13 @@ const printDiff = diff => {
}

module.exports = (options, time) => {
// Check for package.json
if (!fs.existsSync(path.join(options.path, 'package.json'))) {
log.error('No package.json found in the current directory.')
log.error('Please navigate to the correct directory or run npm init.')
return Promise.resolve('Aborted due to missing package.json')
}

const arb = new Arborist(options)
return arb
.reify(options)
Expand Down

0 comments on commit 01f92e0

Please # to comment.