mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add getVersion function to exports for easy access by tooling (ex: CLI).
This commit is contained in:
parent
bd50a15a96
commit
a971361cf2
4 changed files with 28 additions and 1 deletions
|
@ -5,6 +5,9 @@ import markdownlint from "../..";
|
|||
const assert = require("assert");
|
||||
const markdownlintJsonPath = "../../.markdownlint.json";
|
||||
|
||||
const version: string = markdownlint.getVersion();
|
||||
assert(/^\d+\.\d+\.\d+$/.test(version));
|
||||
|
||||
function assertConfiguration(config: markdownlint.Configuration) {
|
||||
assert(!!config);
|
||||
assert.equal(config["line-length"], false);
|
||||
|
|
8
lib/markdownlint.d.ts
vendored
8
lib/markdownlint.d.ts
vendored
|
@ -8,7 +8,7 @@ export = markdownlint;
|
|||
*/
|
||||
declare function markdownlint(options: Options, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback };
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback };
|
||||
}
|
||||
/**
|
||||
* Configuration options.
|
||||
|
@ -82,6 +82,12 @@ declare function readConfig(file: string, parsers: ConfigurationParser[] | ReadC
|
|||
* @returns {Configuration} Configuration object.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[]): Configuration;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
declare function getVersion(): string;
|
||||
declare namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { readConfigPromise as readConfig };
|
||||
|
|
|
@ -985,10 +985,20 @@ function readConfigSync(file, parsers) {
|
|||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
function getVersion() {
|
||||
return require("../package.json").version;
|
||||
}
|
||||
|
||||
// Export a/synchronous/Promise APIs
|
||||
markdownlint.sync = markdownlintSync;
|
||||
markdownlint.readConfig = readConfig;
|
||||
markdownlint.readConfigSync = readConfigSync;
|
||||
markdownlint.getVersion = getVersion;
|
||||
markdownlint.promises = {
|
||||
"markdownlint": markdownlintPromise,
|
||||
"readConfig": readConfigPromise
|
||||
|
|
|
@ -1443,3 +1443,11 @@ $$\n`
|
|||
test.end();
|
||||
});
|
||||
});
|
||||
|
||||
tape("getVersion", (test) => {
|
||||
test.plan(1);
|
||||
const actual = markdownlint.getVersion();
|
||||
const expected = packageJson.version;
|
||||
test.equal(actual, expected, "Version string not correct.");
|
||||
test.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue