Skip to content

Commit

Permalink
Update dependency: commander to 7.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Feb 15, 2021
1 parent 49e00d9 commit f457fdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
21 changes: 11 additions & 10 deletions markdownlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require('fs');
const path = require('path');
const Module = require('module');
const program = require('commander');
const options = program.opts();
const differenceWith = require('lodash.differencewith');
const flatten = require('lodash.flatten');
const markdownlint = require('markdownlint');
Expand Down Expand Up @@ -162,14 +163,14 @@ function printResult(lintResult) {
process.exitCode = 1;
}

if (program.output) {
if (options.output) {
lintResultString = lintResultString.length > 0 ?
lintResultString + os.EOL :
lintResultString;
try {
fs.writeFileSync(program.output, lintResultString);
fs.writeFileSync(options.output, lintResultString);
} catch (error) {
console.warn('Cannot write to output file ' + program.output + ': ' + error.message);
console.warn('Cannot write to output file ' + options.output + ': ' + error.message);
process.exitCode = 2;
}
} else if (lintResultString) {
Expand Down Expand Up @@ -239,8 +240,8 @@ function loadCustomRules(rules) {

let ignorePath = '.markdownlintignore';
let {existsSync} = fs;
if (program.ignorePath) {
ignorePath = program.ignorePath;
if (options.ignorePath) {
ignorePath = options.ignorePath;
existsSync = () => true;
}

Expand All @@ -254,8 +255,8 @@ if (existsSync(ignorePath)) {

const files = prepareFileList(program.args, ['md', 'markdown'])
.filter(value => ignoreFilter(value));
const ignores = prepareFileList(program.ignore, ['md', 'markdown'], files);
const customRules = loadCustomRules(program.rules);
const ignores = prepareFileList(options.ignore, ['md', 'markdown'], files);
const customRules = loadCustomRules(options.rules);
const diff = differenceWith(files, ignores, function (a, b) {
return a.absolute === b.absolute;
}).map(function (paths) {
Expand All @@ -276,7 +277,7 @@ function lintAndPrint(stdin, files) {
};
}

if (program.fix) {
if (options.fix) {
const fixOptions = {
...lintOptions,
resultVersion: 3
Expand All @@ -300,9 +301,9 @@ function lintAndPrint(stdin, files) {
printResult(lintResult);
}

if ((files.length > 0) && !program.stdin) {
if ((files.length > 0) && !options.stdin) {
lintAndPrint(null, diff);
} else if ((files.length === 0) && program.stdin && !program.fix) {
} else if ((files.length === 0) && options.stdin && !options.fix) {
const getStdin = require('get-stdin');
getStdin().then(lintAndPrint);
} else {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
"dependencies": {
"commander": "~6.2.1",
"commander": "~7.1.0",
"deep-extend": "~0.6.0",
"get-stdin": "~8.0.0",
"glob": "~7.1.6",
Expand Down

0 comments on commit f457fdd

Please sign in to comment.