Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdownlint-cli

Package Overview
Dependencies
Maintainers
3
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint-cli - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

43

markdownlint.js

@@ -44,10 +44,17 @@ #!/usr/bin/env node

function prepareFileList(files) {
function prepareFileList(files, fileExtensions) {
var globOptions = {
nodir: true
};
var extensionGlobPart = '*.';
if (fileExtensions.length === 1) {
// Glob seems not to match patterns like 'foo.{js}'
extensionGlobPart += fileExtensions[0];
} else {
extensionGlobPart += '{' + fileExtensions.join(',') + '}';
}
files = files.map(function (file) {
try {
if (fs.lstatSync(file).isDirectory()) {
return glob.sync(path.join(file, '**', '*.{md,markdown}'), globOptions);
return glob.sync(path.join(file, '**', extensionGlobPart), globOptions);
}

@@ -121,8 +128,33 @@ } catch (err) {

.option('-c, --config [configFile]', 'configuration file (JSON or YAML)')
.option('-i, --ignore [file|directory|glob]', 'files to ignore/exclude', concatArray, []);
.option('-i, --ignore [file|directory|glob]', 'files to ignore/exclude', concatArray, [])
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, []);
program.parse(process.argv);
var files = prepareFileList(program.args);
var ignores = prepareFileList(program.ignore);
function loadCustomRuleFromFile(filepath) {
try {
return require(filepath.absolute);
} catch (err) {
console.error('Cannot load custom rule from ' + filepath.original + ': ' + err.message);
process.exit(3);
}
}
function tryResolvePath(filepath) {
try {
if (path.basename(filepath) === filepath && path.extname(filepath) === '') {
// Looks like a package name
return require.resolve(filepath);
}
// Maybe it is a path to package installed locally
return require.resolve(path.join(process.cwd(), filepath));
} catch (err) {
return filepath;
}
}
var files = prepareFileList(program.args, ['md', 'markdown']);
var ignores = prepareFileList(program.ignore, ['md', 'markdown']);
var customRuleFiles = program.rules.map(tryResolvePath);
var customRules = prepareFileList(customRuleFiles, ['js']).map(loadCustomRuleFromFile);
var diff = differenceWith(files, ignores, function (a, b) {

@@ -138,2 +170,3 @@ return a.absolute === b.absolute;

config: config,
customRules: customRules,
files: files || []

@@ -140,0 +173,0 @@ };

11

package.json
{
"name": "markdownlint-cli",
"version": "0.10.0",
"version": "0.11.0",
"description": "MarkdownLint Command Line Interface",

@@ -14,3 +14,3 @@ "main": "markdownlint.js",

"invalid": "node ./markdownlint.js --config test/test-config.json -- test/incorrect.md",
"test": "ava test/",
"test": "ava",
"watch": "npm test -- --watch --tap | tap-growl",

@@ -57,3 +57,4 @@ "start": "node ./markdownlint.js",

"tap-growl": "^1.1.2",
"xo": "*"
"xo": "*",
"test-rule-package": "./test/custom-rules/test-rule-package"
},

@@ -70,2 +71,6 @@ "xo": {

"ava": {
"files": [
"test/**/*.js",
"!test/custom-rules/**/*.js"
],
"failFast": true,

@@ -72,0 +77,0 @@ "babel": {

@@ -22,8 +22,9 @@ # markdownlint-cli [![Travis CI Build Status][travis-badge]][travis-url] [![AppVeyor CI Build Status][appveyor-badge]][appveyor-url]

-h, --help output usage information
-V, --version output the version number
-s, --stdin read from STDIN (no files)
-o, --output [outputFile] write issues to file (no console)
-c, --config [configFile] configuration file (JSON or YAML)
-i, --ignore [file|directory|glob] files to ignore/exclude
-h, --help output usage information
-V, --version output the version number
-s, --stdin read from STDIN (no files)
-o, --output [outputFile] write issues to file (no console)
-c, --config [configFile] configuration file (JSON or YAML)
-i, --ignore [file|directory|glob] files to ignore/exclude
-r, --rules [file|directory|glob|package] custom rule files
```

@@ -30,0 +31,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc