Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant Promise.reject? and then you'd need to wrap the message in a new Error().

But we could just make this async and throw properly too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have resolved this now.

}

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