Add getVersion function to exports for easy access by tooling (ex: CLI).

This commit is contained in:
David Anson 2020-10-17 14:17:35 -07:00
parent bd50a15a96
commit a971361cf2
4 changed files with 28 additions and 1 deletions

View file

@ -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