From 9517e70be7e7053fdf5d67be743cd360c71f819a Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 13:04:13 -0800 Subject: [PATCH] Print helpful message when package.json not found Fixes https://github.com/feross/thanks/issues/69 --- src/cmd.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd.js b/src/cmd.js index b05edad..79b6cfa 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -389,6 +389,13 @@ async function openDonateLinks (donateLinks) { async function readDirectPkgNames () { const pkgPath = await pkgUp() + + if (pkgPath == null) { + throw new Error( + 'No package.json found. Run this in a Node.js project folder!' + ) + } + const pkgStr = await readFileAsync(pkgPath, 'utf8') let pkg