From 2ba9baf6be764e4b79d9ff0c0a02f2ba8f6d3ba1 Mon Sep 17 00:00:00 2001 From: Remy Royer-Adnot Date: Thu, 5 Sep 2019 18:02:17 +0100 Subject: [PATCH] Use config from package.json if .htmllintrc doesn't exists --- bin/cli.js | 16 +++++++++++----- package.json | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index b36b17b..1dc449e 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -92,16 +92,22 @@ app.launch({ return; } - if (!env.configPath) { + var cfg; + + if (env.configPath) { + cfg = cjson.load(env.configPath); + }else{ + cfg = cjson.load('package.json').htmllint; + } + + if (!cfg) { console.log( - chalk.red('local .htmllintrc file not found'), - '(you can create one using "htmllint init")' + chalk.red('No configuration found (local .htmllintrc file not found and no htmllint config in package.json)'), + '(you can create one using "htmllint init")' ); process.exit(1); } - var cfg = cjson.load(env.configPath); - htmllint.use(cfg.plugins || []); delete cfg.plugins; diff --git a/package.json b/package.json index 5b28c8f..f1d0446 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "htmllint-cli", - "version": "0.0.7", + "version": "0.0.71", "description": "A simple cli for htmllint.", "bin": { "htmllint": "./bin/cli.js" @@ -8,13 +8,13 @@ "preferGlobal": true, "repository": { "type": "git", - "url": "https://github.com/htmllint/htmllint-cli.git" + "url": "https://github.com/BabOuDev/htmllint-cli.git" }, "license": "ISC", "bugs": { - "url": "https://github.com/htmllint/htmllint-cli/issues" + "url": "https://github.com/BabOuDev/htmllint-cli/issues" }, - "homepage": "https://github.com/htmllint/htmllint-cli", + "homepage": "https://github.com/BabOuDev/htmllint-cli", "engines": { "node": ">=4" },