From 70850ad8ecbcc9b0bdb8505dadb7e2fabbc0bfb8 Mon Sep 17 00:00:00 2001 From: nunospot Date: Sat, 27 Jul 2019 00:22:49 +0100 Subject: [PATCH 1/7] Check if options.config || pkg is either undefined or null. If so console.log error that package.json is missing --- index.js | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5e4c6b9..2bf4f92 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,10 @@ module.exports = (grunt, options = {}) => { let cwd = process.cwd(); let config = options.config || pkgUp.sync(); + if (['undefined', null].indexOf(config) > 0) { + console.error('\x1b[41m%s\x1b[0m', 'ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); + return false; + } if (typeof config === 'string') { const configPath = path.resolve(config); cwd = path.dirname(configPath); diff --git a/package.json b/package.json index 08c42da..321f8c8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "resolve-pkg": "^2.0.0" }, "devDependencies": { - "grunt": "^1.0.1", + "grunt": "^1.0.4", "grunt-cli": "^1.2.0", "grunt-svgmin": "^6.0.0", "xo": "^0.24.0" From 5a9d1c95cbc485609f3214592f3fa5562e1db737 Mon Sep 17 00:00:00 2001 From: nunospot Date: Sat, 27 Jul 2019 00:27:15 +0100 Subject: [PATCH 2/7] Undo grunt devDependencies patch version upgrade. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 321f8c8..08c42da 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "resolve-pkg": "^2.0.0" }, "devDependencies": { - "grunt": "^1.0.4", + "grunt": "^1.0.1", "grunt-cli": "^1.2.0", "grunt-svgmin": "^6.0.0", "xo": "^0.24.0" From 1cba8e910f5e6cb6b66576de2f2c41b667e05709 Mon Sep 17 00:00:00 2001 From: nunospot Date: Sat, 27 Jul 2019 01:07:02 +0100 Subject: [PATCH 3/7] Fix travis build. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2bf4f92..3a1a130 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,11 @@ module.exports = (grunt, options = {}) => { let cwd = process.cwd(); let config = options.config || pkgUp.sync(); - if (['undefined', null].indexOf(config) > 0) { - console.error('\x1b[41m%s\x1b[0m', 'ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); + if (['undefined', undefined, null].indexOf(config) > 0) { + console.error('ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); return false; } + if (typeof config === 'string') { const configPath = path.resolve(config); cwd = path.dirname(configPath); From a8acf309d5714ae0da2f187bccc56ac213ec9ae6 Mon Sep 17 00:00:00 2001 From: nunospot Date: Sat, 27 Jul 2019 21:28:08 +0100 Subject: [PATCH 4/7] Change on config validation - only check if is null. Add red color to error. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3a1a130..6d35f62 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,9 @@ module.exports = (grunt, options = {}) => { let cwd = process.cwd(); let config = options.config || pkgUp.sync(); - if (['undefined', undefined, null].indexOf(config) > 0) { - console.error('ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); - return false; + + if (config === null) { + console.error('\u001B[41m%s\u001B[0m', 'ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); } if (typeof config === 'string') { From fbde14ea3ab71d6133357996d6ef1cbc4ec564ce Mon Sep 17 00:00:00 2001 From: nunospot Date: Mon, 29 Jul 2019 20:02:27 +0100 Subject: [PATCH 5/7] Change log error to grunt.fail.fatal. Improvement of the log message. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6d35f62..cf05099 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ module.exports = (grunt, options = {}) => { let config = options.config || pkgUp.sync(); if (config === null) { - console.error('\u001B[41m%s\u001B[0m', 'ABORTED: package.json not found.\nPlease be sure to create a package.json and install all dependecies before run a grunt task.'); + grunt.fail.fatal('package.json not found.\nPlease make sure to create a package.json and install all dependecies before run a grunt task.'); } if (typeof config === 'string') { From 705ce88db9ebffb291216fb61eeae02b6138c8b1 Mon Sep 17 00:00:00 2001 From: nunospot Date: Tue, 30 Jul 2019 20:38:08 +0100 Subject: [PATCH 6/7] Fix typos. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index cf05099..9b8725e 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ module.exports = (grunt, options = {}) => { let config = options.config || pkgUp.sync(); if (config === null) { - grunt.fail.fatal('package.json not found.\nPlease make sure to create a package.json and install all dependecies before run a grunt task.'); + grunt.fail.fatal('package.json not found.\nPlease make sure to create a package.json and install all dependencies before you run Grunt.'); } if (typeof config === 'string') { From abb2bc5f679c4eea96c8ab6ec6e5746438ee309b Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 31 Jul 2019 02:04:29 +0200 Subject: [PATCH 7/7] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9b8725e..8bbfc9e 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ module.exports = (grunt, options = {}) => { let config = options.config || pkgUp.sync(); if (config === null) { - grunt.fail.fatal('package.json not found.\nPlease make sure to create a package.json and install all dependencies before you run Grunt.'); + 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') {