Skip to content

Commit

Permalink
Fix bug introduced during commander upgrade that caused -c/--config n…
Browse files Browse the repository at this point in the history
…ot to be honored for non-JSON files (fixes #173).
  • Loading branch information
DavidAnson committed Mar 2, 2021
1 parent d0051f7 commit f2e4c4d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions markdownlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ const configFileParsers = [jsoncParse, jsYamlSafeLoad];
const fsOptions = {encoding: 'utf8'};
const processCwd = process.cwd();

function readConfiguration(args) {
const userConfigFile = args.config;
function readConfiguration(userConfigFile) {
const jsConfigFile = /\.js$/i.test(userConfigFile);
const rcArgv = minimist(process.argv.slice(2));
if (jsConfigFile) {
Expand Down Expand Up @@ -268,7 +267,7 @@ const diff = differenceWith(files, ignores, function (a, b) {

function lintAndPrint(stdin, files) {
files = files || [];
const config = readConfiguration(program);
const config = readConfiguration(options.config);
const lintOptions = {
config,
customRules,
Expand Down
1 change: 1 addition & 0 deletions test/md043-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// -OR-
// via require('some-npm-module-that-exports-config')
module.exports = {
MD012: false,
MD043: {
headers: [
'# First',
Expand Down
1 change: 1 addition & 0 deletions test/md043-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"MD012": false,
"MD043": {
"headers": [
"# First",
Expand Down
3 changes: 3 additions & 0 deletions test/md043-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Text
Text

### Third

Extra newline at end of file is sentinel to ensure config file is used

1 change: 1 addition & 0 deletions test/md043-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MD012: false
MD043:
headers:
- "# First"
Expand Down

0 comments on commit f2e4c4d

Please sign in to comment.