From 6234bc9874511c759c952fe9f6467298217a00e8 Mon Sep 17 00:00:00 2001 From: nunospot Date: Wed, 31 Jul 2019 01:05:37 +0100 Subject: [PATCH] Print a useful error if package.json is missing (#61) Co-authored-by: Sindre Sorhus --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 5e4c6b9..8bbfc9e 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,11 @@ module.exports = (grunt, options = {}) => { let cwd = process.cwd(); let config = options.config || pkgUp.sync(); + + if (config === null) { + grunt.fail.fatal('package.json not found. Make sure to create a package.json and install dependencies before you run Grunt.'); + } + if (typeof config === 'string') { const configPath = path.resolve(config); cwd = path.dirname(configPath);