forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown-magic.js
36 lines (31 loc) · 1.28 KB
/
markdown-magic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
const chalk = require("chalk");
const markdownMagic = require("@tylerbu/markdown-magic");
const process = require("process");
const config = require("./md-magic.config.js");
/**
* Runs Markdown Magic in the specified working directory.
* Searches all `.md` files for processing.
*
* @param {string} workingDirectory - Directory in which to run Markdown Magic.
* @param {string | string[]} matchPatterns - File name(s) / glob pattern(s) to file match on.
* See {@link https://www.npmjs.com/package/@tylerbu/markdown-magic | @tylerbu/markdown-magic} for specific
* requirements.
*/
function main(workingDirectory, matchPatterns) {
process.chdir(workingDirectory);
console.log(`Searching for markdown files in "${workingDirectory}" matching pattern(s) "${matchPatterns}"...`);
markdownMagic(matchPatterns, config).then(
() => {
console.log(chalk.green(`SUCCESS: Markdown Magic completed in "${workingDirectory}"!`));
process.exit(0);
},
(error) => {
console.error("FAILURE: Markdown Magic could not be completed due to an error.", error);
process.exit(1);
});
}
module.exports = main;