From ef7ae5d4d202987d31a2bd7c95ee84ea1f7779c3 Mon Sep 17 00:00:00 2001 From: Ryan Rhee Date: Wed, 28 Oct 2020 18:18:59 -0400 Subject: [PATCH] Gracefully handle package.json not being found (#167) Co-authored-by: Sindre Sorhus --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c726013..7cddcfd 100644 --- a/index.js +++ b/index.js @@ -91,11 +91,13 @@ const meow = (helpText, options) => { helpText = ''; } + const foundPkg = readPkgUp.sync({ + cwd: parentDir, + normalize: false + }); + options = { - pkg: readPkgUp.sync({ - cwd: parentDir, - normalize: false - }).packageJson || {}, + pkg: foundPkg ? foundPkg.packageJson : {}, argv: process.argv.slice(2), flags: {}, inferType: false,