Handle non-Array inputs for options.files.

This commit is contained in:
David Anson 2016-01-15 22:00:34 -08:00
parent c4a0e6c312
commit 1e23d035ce
2 changed files with 19 additions and 1 deletions

View file

@ -230,7 +230,12 @@ function markdownlint(options, callback) {
// Normalize inputs
options = options || {};
callback = callback || function noop() {};
var files = (options.files || []).slice();
var files = [];
if (Array.isArray(options.files)) {
files = options.files.slice();
} else if (options.files) {
files = [ String(options.files) ];
}
var strings = options.strings || {};
var frontMatter = (options.frontMatter === undefined) ?
shared.frontMatterRe : options.frontMatter;

View file

@ -643,6 +643,19 @@ module.exports.filesArrayNotModified = function filesArrayNotModified(test) {
});
};
module.exports.filesArrayAsString = function filesArrayAsString(test) {
test.expect(2);
markdownlint({
"files": "README.md",
"config": { "MD013": false }
}, function callback(err, actual) {
test.ifError(err);
var expected = { "README.md": {} };
test.deepEqual(actual, expected, "Unexpected issues.");
test.done();
});
};
module.exports.missingOptions = function missingOptions(test) {
test.expect(2);
markdownlint(null, function callback(err, result) {