markdown-table-formatter 1.0.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.0] 2022-01-31
4
+
5
+ - Allow to override the table columns padding number of spaces using argument **--columnpadding**
6
+ - CI: Upgrade MegaLinter to v5 + fix CI tests on Windows & Mac
7
+
8
+ ## [1.2.0] 2021-08-20
9
+
10
+ - Allow to call markdown-table-formatter with a glob parameter to find files to format
11
+ - Allow to call markdown-table-formatter without arguments (**/*.md will be used by default to collect files)
12
+ - Fix logs format
13
+
14
+ ## [1.1.0] 2021-04-05
15
+
16
+ - Upgrade markdown-table-prettify to 3.4.0 so it can take in account inline disable comments
17
+
3
18
  ## [1.0.2] 2021-01-19
4
19
 
5
20
  - Fix code coverage
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Nicolas Vuillamy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nicolas Vuillamy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,101 +1,114 @@
1
- <!-- markdownlint-disable MD033 MD041 -->
2
-
3
- [![Banner](https://raw.githubusercontent.com/nvuillam/markdown-table-formatter/master/docs/assets/images/banner.jpg)](https://github.com/nvuillam/markdown-table-formatter#readme)
4
-
5
- # Markdown table formatter
6
-
7
- [![Version](https://img.shields.io/npm/v/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
8
- [![Downloads/week](https://img.shields.io/npm/dw/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
9
- [![Downloads/total](https://img.shields.io/npm/dt/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
10
- [![Mega-Linter](https://github.com/nvuillam/markdown-table-formatter/workflows/Mega-Linter/badge.svg)](https://github.com/nvuillam/mega-linter#readme)
11
- [![codecov](https://codecov.io/gh/nvuillam/markdown-table-formatter/branch/master/graph/badge.svg)](https://codecov.io/gh/nvuillam/markdown-table-formatter)
12
- [![GitHub contributors](https://img.shields.io/github/contributors/nvuillam/markdown-table-formatter.svg)](https://gitHub.com/nvuillam/markdown-table-formatter/graphs/contributors/)
13
- [![GitHub stars](https://img.shields.io/github/stars/nvuillam/markdown-table-formatter?label=Star&maxAge=2592000)](https://GitHub.com/nvuillam/markdown-table-formatter/stargazers/)
14
- [![License](https://img.shields.io/npm/l/markdown-table-formatter.svg)](https://github.com/nvuillam/markdown-table-formatter/blob/master/LICENSE)
15
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
16
-
17
- Format markdown tables in files, using embedded [markdown-table-prettify](https://www.npmjs.com/package/markdown-table-prettify)
18
-
19
- ## Installation
20
-
21
- ### Local
22
-
23
- ```shell
24
- npm install markdown-table-formatter --save
25
- ```
26
-
27
- ### Global
28
-
29
- ```shell
30
- npm install markdown-table-formatter -g
31
- ```
32
-
33
- ## Usage
34
-
35
- ```shell
36
- markdown-table-formatter [OPTIONS] (file(s))
37
- ```
38
-
39
- ### Options
40
-
41
- | Parameter | Description | Default value |
42
- |------------------|-----------------------------------|---------------|
43
- | -c<br/>--check | Check only, does not update files | `false` |
44
- | -h<br/>--help | Displays help | <!-- --> |
45
- | -v<br/>--version | Displays version | <!-- --> |
46
-
47
- ## Examples
48
-
49
- Format markdown tables in a single file
50
-
51
- ```shell
52
- markdown-table-formatter myfile.md
53
- ```
54
-
55
- Format markdown tables in a multiple file
56
-
57
- ```shell
58
- markdown-table-formatter myfile.md anotherFile.md andAnotherFile.md
59
- ```
60
-
61
- Check if markdown table formatting is necessary in a single file
62
-
63
- ```shell
64
- markdown-table-formatter --check myfile.md
65
- ```
66
-
67
- Check if markdown table formatting is necessary in a multiple files
68
-
69
- ```shell
70
- markdown-table-formatter --check myfile.md anotherFile.md andAnotherFile.md
71
- ```
72
-
73
- You can see **more examples in** [**test methods**](https://github.com/nvuillam/markdown-table-formatter/blob/master/test/markdown-table-formatter.test.js)
74
-
75
- ## Continuous Integration
76
-
77
- You can automatically check markdown tables formatting and fix it using [Mega-Linter](https://github.com/nvuillam/mega-linter/), that embeds markdown-table-formatter out of the box
78
-
79
- ## CONTRIBUTE
80
-
81
- Contributions are very welcome !
82
-
83
- Please follow [Contribution instructions](https://github.com/nvuillam/markdown-table-formatter/blob/master/CONTRIBUTING.md)
84
-
85
- ## RELEASE NOTES
86
-
87
- ## [1.0.2] 2021-01-19
88
-
89
- - Fix code coverage
90
-
91
- ## [1.0.1] 2021-01-13
92
-
93
- - First working version :)
94
-
95
- ## [0.0.1] 2021-01-13
96
-
97
- - Initial version
98
-
99
- ____
100
-
101
- See complete [CHANGELOG](https://github.com/nvuillam/markdown-table-formatter/blob/master/CHANGELOG.md)
1
+ <!-- markdownlint-disable MD033 MD041 -->
2
+
3
+ # Markdown table formatter
4
+
5
+ [![Version](https://img.shields.io/npm/v/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
6
+ [![Downloads/week](https://img.shields.io/npm/dw/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
7
+ [![Downloads/total](https://img.shields.io/npm/dt/markdown-table-formatter.svg)](https://npmjs.org/package/markdown-table-formatter)
8
+ [![Mega-Linter](https://github.com/nvuillam/markdown-table-formatter/workflows/Mega-Linter/badge.svg)](https://github.com/nvuillam/mega-linter#readme)
9
+ [![codecov](https://codecov.io/gh/nvuillam/markdown-table-formatter/branch/master/graph/badge.svg)](https://codecov.io/gh/nvuillam/markdown-table-formatter)
10
+ [![GitHub contributors](https://img.shields.io/github/contributors/nvuillam/markdown-table-formatter.svg)](https://gitHub.com/nvuillam/markdown-table-formatter/graphs/contributors/)
11
+ [![GitHub stars](https://img.shields.io/github/stars/nvuillam/markdown-table-formatter?label=Star&maxAge=2592000)](https://GitHub.com/nvuillam/markdown-table-formatter/stargazers/)
12
+ [![License](https://img.shields.io/npm/l/markdown-table-formatter.svg)](https://github.com/nvuillam/markdown-table-formatter/blob/master/LICENSE)
13
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
14
+
15
+ Format markdown tables in files, using embedded [markdown-table-prettify](https://www.npmjs.com/package/markdown-table-prettify)
16
+
17
+ [![Banner](https://raw.githubusercontent.com/nvuillam/markdown-table-formatter/master/docs/assets/images/banner.jpg)](https://github.com/nvuillam/markdown-table-formatter#readme)
18
+
19
+ ## Installation
20
+
21
+ ### Local
22
+
23
+ ```shell
24
+ npm install markdown-table-formatter --save
25
+ ```
26
+
27
+ ### Global
28
+
29
+ ```shell
30
+ npm install markdown-table-formatter -g
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```shell
36
+ markdown-table-formatter [OPTIONS] (file(s) or glob expression)
37
+ ```
38
+
39
+ ### Options
40
+
41
+ | Parameter | Description | Default value |
42
+ |----------------|-----------------------------------|---------------|
43
+ | -c<br/>--check | Check only, does not update files | `false` |
44
+ | -p<br/>--columnpadding | Override column padding number of spaces |
45
+ | -h<br/>--help | Displays help | <!-- --> |
46
+ | -v<br/>--version | Displays version | <!-- --> |
47
+
48
+ ## Examples
49
+
50
+ Format all markdown files found within current directory
51
+
52
+ ```shell
53
+ markdown-table-formatter
54
+ ```
55
+
56
+ Format all markdown files found with a glob expression
57
+
58
+ ```shell
59
+ markdown-table-formatter **/docs/*.md
60
+ ```
61
+
62
+ Format markdown tables in a single file
63
+
64
+ ```shell
65
+ markdown-table-formatter myfile.md
66
+ ```
67
+
68
+ Format markdown tables in a multiple file
69
+
70
+ ```shell
71
+ markdown-table-formatter myfile.md anotherFile.md andAnotherFile.md
72
+ ```
73
+
74
+ Check if markdown table formatting is necessary in a single file
75
+
76
+ ```shell
77
+ markdown-table-formatter --check myfile.md
78
+ ```
79
+
80
+ Check if markdown table formatting is necessary in a multiple files
81
+
82
+ ```shell
83
+ markdown-table-formatter --check myfile.md anotherFile.md andAnotherFile.md
84
+ ```
85
+
86
+ You can see **more examples in** [**test methods**](https://github.com/nvuillam/markdown-table-formatter/blob/master/test/markdown-table-formatter.test.js)
87
+
88
+ ## Continuous Integration
89
+
90
+ You can automatically check markdown tables formatting and fix it using [Mega-Linter](https://github.com/nvuillam/mega-linter/), that embeds markdown-table-formatter out of the box
91
+
92
+ ## CONTRIBUTE
93
+
94
+ Contributions are very welcome !
95
+
96
+ Please follow [Contribution instructions](https://github.com/nvuillam/markdown-table-formatter/blob/master/CONTRIBUTING.md)
97
+
98
+ ## RELEASE NOTES
99
+
100
+ ## [1.0.2] 2021-01-19
101
+
102
+ - Fix code coverage
103
+
104
+ ## [1.0.1] 2021-01-13
105
+
106
+ - First working version :)
107
+
108
+ ## [0.0.1] 2021-01-13
109
+
110
+ - Initial version
111
+
112
+ ____
113
+
114
+ See complete [CHANGELOG](https://github.com/nvuillam/markdown-table-formatter/blob/master/CHANGELOG.md)
package/lib/cli.js CHANGED
@@ -1,62 +1,77 @@
1
- #! /usr/bin/env node
2
- const { MarkdownTableFormatter } = require("./markdown-table-formatter");
3
- const optionsDefinition = require("./options");
4
-
5
- class MarkdownTableFormatterCli {
6
- "use strict";
7
-
8
- options = {};
9
-
10
- async run(args) {
11
- this.options = optionsDefinition.parse(args);
12
-
13
- // Show version
14
- if (this.options.version) {
15
- let version = process.env.npm_package_version;
16
- if (!version) {
17
- try {
18
- const FindPackageJson = require("find-package-json");
19
- const finder = FindPackageJson(__dirname);
20
- version = finder.next().value.version;
21
- } catch {
22
- version = "error";
23
- }
24
- }
25
- const message = `markdown-table-formatter version ${version}`;
26
- console.log(message);
27
- return { stdout: message };
28
- }
29
-
30
- // Show help ( index or for an options)
31
- if (this.options.help) {
32
- let helpContent = "";
33
- if (this.options._.length) {
34
- helpContent = optionsDefinition.generateHelpForOption(this.options._[0]);
35
- } else {
36
- helpContent = optionsDefinition.generateHelp();
37
- }
38
- console.info(helpContent);
39
- return { stdout: helpContent };
40
- }
41
-
42
- // Processing formatting
43
- const formatter = new MarkdownTableFormatter(this.options);
44
- const files = this.options._;
45
- if (files.length === 0) {
46
- throw new Error("You must send a file or a list of files as argument");
47
- }
48
- const { status, updates } = await formatter.run(files);
49
- // Manage result
50
- if (status === 0 && updates.length === 0) {
51
- console.log("No markdown table formatting has been applied.");
52
- } else if (status === 0 && updates > 0) {
53
- console.log(`Formatted markdown tables in ${updates.length} files: - \n${updates.join("\n- ")}`);
54
- } else if (status === 1) {
55
- console.log(`${updates.length} files contain markdown tables to format: - \n${updates.join("\n- ")}`);
56
- }
57
- process.exitCode = status;
58
- return { status, updates };
59
- }
60
- }
61
-
62
- module.exports = { MarkdownTableFormatterCli };
1
+ #! /usr/bin/env node
2
+ const { MarkdownTableFormatter } = require("./markdown-table-formatter");
3
+ const optionsDefinition = require("./options");
4
+ const glob = require("glob");
5
+
6
+ class MarkdownTableFormatterCli {
7
+ "use strict";
8
+
9
+ options = {};
10
+
11
+ async run(args) {
12
+ this.options = optionsDefinition.parse(args);
13
+
14
+ // Show version
15
+ if (this.options.version) {
16
+ let version = process.env.npm_package_version;
17
+ if (!version) {
18
+ try {
19
+ const FindPackageJson = require("find-package-json");
20
+ const finder = FindPackageJson(__dirname);
21
+ version = finder.next().value.version;
22
+ } catch {
23
+ version = "error";
24
+ }
25
+ }
26
+ const message = `markdown-table-formatter version ${version}`;
27
+ console.log(message);
28
+ return { stdout: message };
29
+ }
30
+
31
+ // Show help ( index or for an options)
32
+ if (this.options.help) {
33
+ let helpContent = "";
34
+ if (this.options._.length) {
35
+ helpContent = optionsDefinition.generateHelpForOption(
36
+ this.options._[0]
37
+ );
38
+ } else {
39
+ helpContent = optionsDefinition.generateHelp();
40
+ }
41
+ console.info(helpContent);
42
+ return { stdout: helpContent };
43
+ }
44
+
45
+ // Processing formatting
46
+ const formatter = new MarkdownTableFormatter(this.options);
47
+ let files = this.options._;
48
+ if (files.length === 0) {
49
+ // use default glob expression **/*.md
50
+ files = glob.sync("**/*.md", {});
51
+ } else if (files.length === 1 && files[0].includes("*")) {
52
+ // use sent glob expression
53
+ files = glob.sync(files[0], {});
54
+ }
55
+ const { status, updates } = await formatter.run(files, this.options);
56
+ // Manage result
57
+ if (status === 0 && updates.length === 0) {
58
+ console.log("No markdown table formatting has been applied.");
59
+ } else if (status === 0 && updates > 0) {
60
+ console.log(
61
+ `Formatted markdown tables in ${
62
+ updates.length
63
+ } files:\n- ${updates.join("\n- ")}`
64
+ );
65
+ } else if (status === 1) {
66
+ console.log(
67
+ `${
68
+ updates.length
69
+ } files contain markdown tables to format:\n- ${updates.join("\n- ")}`
70
+ );
71
+ }
72
+ process.exitCode = status;
73
+ return { status, updates };
74
+ }
75
+ }
76
+
77
+ module.exports = { MarkdownTableFormatterCli };
package/lib/index.js CHANGED
@@ -1,17 +1,17 @@
1
- #! /usr/bin/env node
2
- "use strict";
3
-
4
- const { MarkdownTableFormatter } = require("./markdown-table-formatter");
5
- const { MarkdownTableFormatterCli } = require("./cli");
6
-
7
- // Run only if called by script
8
- const runningAsScript = !module.parent;
9
-
10
- // Run asynchronously to use the returned status for process.exit
11
- if (runningAsScript) {
12
- (async () => {
13
- await new MarkdownTableFormatterCli().run(process.argv);
14
- })();
15
- }
16
-
17
- module.exports = { MarkdownTableFormatter, MarkdownTableFormatterCli };
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+
4
+ const { MarkdownTableFormatter } = require("./markdown-table-formatter");
5
+ const { MarkdownTableFormatterCli } = require("./cli");
6
+
7
+ // Run only if called by script
8
+ const runningAsScript = !module.parent;
9
+
10
+ // Run asynchronously to use the returned status for process.exit
11
+ if (runningAsScript) {
12
+ (async () => {
13
+ await new MarkdownTableFormatterCli().run(process.argv);
14
+ })();
15
+ }
16
+
17
+ module.exports = { MarkdownTableFormatter, MarkdownTableFormatterCli };
@@ -1,64 +1,73 @@
1
- #! /usr/bin/env node
2
- const debug = require("debug")("markdown-table-formatter");
3
- const fse = require("fs-extra");
4
- const { CliPrettify } = require("markdown-table-prettify");
5
-
6
- class MarkdownTableFormatter {
7
- "use strict";
8
-
9
- /**
10
- * Creates a MarkdownTableFormatter instance
11
- * @param {object} [opts] - Run options
12
- * @param {string} [opts.check] - Define if we check only
13
- */
14
- constructor(opts) {
15
- this.checkOnly = opts.check;
16
- }
17
-
18
- /**
19
- * Runs markdown table formatter
20
- * @param {string[]} [files] - List of files to format
21
- * @return {Promise<any>} - Command result (status, stdout, stderr, childJavaProcess)
22
- */
23
- async run(files) {
24
- const fileResults = [];
25
- // Read files and call prettify on each of them
26
- for (const file of files) {
27
- if (debug.enabled) {
28
- debug(`[file] ${file}`);
29
- }
30
- const markdown = await fse.readFile(file);
31
- const markdownString = markdown.toString();
32
- if (debug.enabled) {
33
- debug(`[file before]\n${markdownString}`);
34
- }
35
- const markdownStringPrettified = CliPrettify.prettify(markdownString);
36
- const updated = markdownStringPrettified !== markdownString;
37
- // Update file if necessary
38
- if (updated && !this.checkOnly) {
39
- await fse.writeFile(file, markdownStringPrettified);
40
- debug(`[updated] ${file} with:\n${markdownStringPrettified}`);
41
- }
42
- const fileResult = {
43
- file,
44
- updated,
45
- before: updated ? markdownString : null,
46
- after: updated ? markdownStringPrettified : null
47
- };
48
- fileResults.push(fileResult);
49
- }
50
- const updates = fileResults.filter(fileResult => fileResult.updated).map(fileResult => fileResult.file);
51
- let status = 0;
52
- if (this.checkOnly && updates.length > 0) {
53
- status = 1;
54
- }
55
- const result = {
56
- status,
57
- fileResults,
58
- updates
59
- };
60
- return result;
61
- }
62
- }
63
-
64
- module.exports = { MarkdownTableFormatter };
1
+ #! /usr/bin/env node
2
+ const debug = require("debug")("markdown-table-formatter");
3
+ const fse = require("fs-extra");
4
+ const { CliPrettify } = require("markdown-table-prettify");
5
+
6
+ class MarkdownTableFormatter {
7
+ "use strict";
8
+
9
+ /**
10
+ * Creates a MarkdownTableFormatter instance
11
+ * @param {object} [opts] - Run options
12
+ * @param {string} [opts.check] - Define if we check only
13
+ */
14
+ constructor(opts) {
15
+ this.checkOnly = opts.check;
16
+ }
17
+
18
+ /**
19
+ * Runs markdown table formatter
20
+ * @param {string[]} [files] - List of files to format
21
+ * @return {Promise<any>} - Command result (status, stdout, stderr, childJavaProcess)
22
+ */
23
+ async run(files, options = {}) {
24
+ const fileResults = [];
25
+ // Read files and call prettify on each of them
26
+ for (const file of files) {
27
+ if (debug.enabled) {
28
+ debug(`[file] ${file}`);
29
+ }
30
+ const markdown = await fse.readFile(file);
31
+ const markdownString = markdown.toString();
32
+ if (debug.enabled) {
33
+ debug(`[file before]\n${markdownString}`);
34
+ }
35
+ const prettifyOptions = {};
36
+ if (options.columnpadding) {
37
+ prettifyOptions.columnPadding = options.columnpadding;
38
+ }
39
+ const markdownStringPrettified = CliPrettify.prettify(
40
+ markdownString,
41
+ prettifyOptions
42
+ );
43
+ const updated = markdownStringPrettified !== markdownString;
44
+ // Update file if necessary
45
+ if (updated && !this.checkOnly) {
46
+ await fse.writeFile(file, markdownStringPrettified);
47
+ debug(`[updated] ${file} with:\n${markdownStringPrettified}`);
48
+ }
49
+ const fileResult = {
50
+ file,
51
+ updated,
52
+ before: updated ? markdownString : null,
53
+ after: updated ? markdownStringPrettified : null,
54
+ };
55
+ fileResults.push(fileResult);
56
+ }
57
+ const updates = fileResults
58
+ .filter((fileResult) => fileResult.updated)
59
+ .map((fileResult) => fileResult.file);
60
+ let status = 0;
61
+ if (this.checkOnly && updates.length > 0) {
62
+ status = 1;
63
+ }
64
+ const result = {
65
+ status,
66
+ fileResults,
67
+ updates,
68
+ };
69
+ return result;
70
+ }
71
+ }
72
+
73
+ module.exports = { MarkdownTableFormatter };
package/lib/options.js CHANGED
@@ -1,46 +1,53 @@
1
- /**
2
- * @fileoverview Options configuration for optionator.
3
- * @author Nicolas Vuillamy
4
- */
5
-
6
- "use strict";
7
-
8
- //------------------------------------------------------------------------------
9
- // Requirements
10
- //------------------------------------------------------------------------------
11
-
12
- const optionator = require("optionator");
13
-
14
- //------------------------------------------------------------------------------
15
- // Initialization and Public Interface
16
- //------------------------------------------------------------------------------
17
-
18
- // exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)"
19
- module.exports = optionator({
20
- prepend: "markdown-table-formatter [options]",
21
- defaults: {
22
- concatRepeatedArrays: true,
23
- mergeRepeatedObjects: true
24
- },
25
- options: [
26
- {
27
- option: "check",
28
- alias: "c",
29
- type: "Boolean",
30
- description: "Check only (exits 1 if wrongly formatted markdown tables are found)"
31
- },
32
- {
33
- option: "help",
34
- alias: "h",
35
- type: "Boolean",
36
- description: "Show help"
37
- },
38
- {
39
- option: "version",
40
- alias: "v",
41
- type: "Boolean",
42
- description: "Show version"
43
- }
44
- ],
45
- mutuallyExclusive: [["check", "help", "version"]]
46
- });
1
+ /**
2
+ * @fileoverview Options configuration for optionator.
3
+ * @author Nicolas Vuillamy
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const optionator = require("optionator");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Initialization and Public Interface
16
+ //------------------------------------------------------------------------------
17
+
18
+ // exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)"
19
+ module.exports = optionator({
20
+ prepend: "markdown-table-formatter [options]",
21
+ defaults: {
22
+ concatRepeatedArrays: true,
23
+ mergeRepeatedObjects: true,
24
+ },
25
+ options: [
26
+ {
27
+ option: "check",
28
+ alias: "c",
29
+ type: "Boolean",
30
+ description:
31
+ "Check only (exits 1 if wrongly formatted markdown tables are found)",
32
+ },
33
+ {
34
+ option: "columnpadding",
35
+ alias: "p",
36
+ type: "Int",
37
+ description: "Override table columns padding number of spaces",
38
+ },
39
+ {
40
+ option: "help",
41
+ alias: "h",
42
+ type: "Boolean",
43
+ description: "Show help",
44
+ },
45
+ {
46
+ option: "version",
47
+ alias: "v",
48
+ type: "Boolean",
49
+ description: "Show version",
50
+ },
51
+ ],
52
+ mutuallyExclusive: [["check", "help", "version"]],
53
+ });
package/package.json CHANGED
@@ -1,76 +1,77 @@
1
- {
2
- "name": "markdown-table-formatter",
3
- "version": "1.0.3",
4
- "description": "Format markdown tables in files",
5
- "main": "./lib/index.js",
6
- "files": [
7
- "lib/"
8
- ],
9
- "bin": {
10
- "markdown-table-formatter": "lib/index.js"
11
- },
12
- "scripts": {
13
- "lint:fix": "eslint **/*.js --fix && prettier --write \"./lib/**/*.{js,jsx,json}\" --tab-width 4 --print-width 150",
14
- "test": "mocha \"test/**/*.test.js\"",
15
- "test:coverage": "nyc npm run test",
16
- "test:debug": "env DEBUG=markdown-table-formatter mocha --reporter spec \"test/**/*.test.js\""
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/nvuillam/markdown-table-formatter.git"
21
- },
22
- "keywords": [
23
- "markdown",
24
- "table",
25
- "formatter",
26
- "format",
27
- "prettify"
28
- ],
29
- "author": "Nicolas Vuillamy",
30
- "license": "MIT",
31
- "bugs": {
32
- "url": "https://github.com/nvuillam/markdown-table-formatter/issues"
33
- },
34
- "homepage": "https://github.com/nvuillam/markdown-table-formatter#readme",
35
- "dependencies": {
36
- "debug": "^4.1.1",
37
- "find-package-json": "^1.2.0",
38
- "fs-extra": "^9.0.1",
39
- "markdown-table-prettify": "^3.2.2",
40
- "optionator": "^0.9.1"
41
- },
42
- "devDependencies": {
43
- "babel-eslint": "^10.1.0",
44
- "eslint": "^7.6.0",
45
- "mega-linter-runner": "^4.23.1",
46
- "mocha": "^8.1.1",
47
- "nyc": "^15.1.0",
48
- "which": "^2.0.2"
49
- },
50
- "engines": {
51
- "node": ">=12.0.0"
52
- },
53
- "mocha": {
54
- "require": [
55
- "test/helpers/init.js"
56
- ],
57
- "watch-extensions": [
58
- "js"
59
- ],
60
- "recursive": true,
61
- "reporter": "spec",
62
- "timeout": "300000"
63
- },
64
- "nyc": {
65
- "include": [
66
- "lib/**"
67
- ],
68
- "extension": [
69
- ".js"
70
- ],
71
- "reporter": [
72
- "html"
73
- ],
74
- "all": true
75
- }
76
- }
1
+ {
2
+ "name": "markdown-table-formatter",
3
+ "version": "1.3.0",
4
+ "description": "Format markdown tables in files",
5
+ "main": "./lib/index.js",
6
+ "files": [
7
+ "lib/"
8
+ ],
9
+ "bin": {
10
+ "markdown-table-formatter": "lib/index.js"
11
+ },
12
+ "scripts": {
13
+ "lint:fix": "eslint **/*.js --fix && prettier --write \"./lib/**/*.{js,jsx,json}\" --tab-width 4 --print-width 150",
14
+ "test": "mocha \"test/**/*.test.js\"",
15
+ "test:coverage": "nyc npm run test",
16
+ "test:debug": "env DEBUG=markdown-table-formatter mocha --reporter spec \"test/**/*.test.js\""
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/nvuillam/markdown-table-formatter.git"
21
+ },
22
+ "keywords": [
23
+ "markdown",
24
+ "table",
25
+ "formatter",
26
+ "format",
27
+ "prettify"
28
+ ],
29
+ "author": "Nicolas Vuillamy",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/nvuillam/markdown-table-formatter/issues"
33
+ },
34
+ "homepage": "https://github.com/nvuillam/markdown-table-formatter#readme",
35
+ "dependencies": {
36
+ "debug": "^4.1.1",
37
+ "find-package-json": "^1.2.0",
38
+ "fs-extra": "^9.0.1",
39
+ "glob": "^7.1.6",
40
+ "markdown-table-prettify": "^3.6.0",
41
+ "optionator": "^0.9.1"
42
+ },
43
+ "devDependencies": {
44
+ "@babel/eslint-parser": "^7.16.5",
45
+ "eslint": "^7.6.0",
46
+ "mega-linter-runner": "^4.23.1",
47
+ "mocha": "^8.1.1",
48
+ "nyc": "^15.1.0",
49
+ "which": "^2.0.2"
50
+ },
51
+ "engines": {
52
+ "node": ">=12.0.0"
53
+ },
54
+ "mocha": {
55
+ "require": [
56
+ "test/helpers/init.js"
57
+ ],
58
+ "watch-extensions": [
59
+ "js"
60
+ ],
61
+ "recursive": true,
62
+ "reporter": "spec",
63
+ "timeout": "300000"
64
+ },
65
+ "nyc": {
66
+ "include": [
67
+ "lib/**"
68
+ ],
69
+ "extension": [
70
+ ".js"
71
+ ],
72
+ "reporter": [
73
+ "html"
74
+ ],
75
+ "all": true
76
+ }
77
+ }