Open sitch opened 3 years ago
Maybe there is an easier/more idiomatic way to integrate this? i.e. formatters and move the current chalk version into one, as well as having a markdown one.
Merging #229 (414f844) into master (57989a2) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #229 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 399 476 +77
Branches 98 117 +19
=========================================
+ Hits 399 476 +77
Impacted Files | Coverage Δ | |
---|---|---|
src/bin-utils/index.js | 100.00% <ø> (ø) |
|
src/index.js | 100.00% <0.00%> (ø) |
|
src/get-logger.js | 100.00% <0.00%> (ø) |
|
src/bin-utils/parser.js | 100.00% <0.00%> (ø) |
|
src/get-script-to-run.js | 100.00% <0.00%> (ø) |
|
src/kebab-and-camel-casify.js | 100.00% <0.00%> (ø) |
|
src/get-scripts-from-config.js | 100.00% <0.00%> (ø) |
|
src/bin-utils/initialize/index.js | 100.00% <0.00%> (ø) |
|
src/bin-utils/get-script-by-prefix.js | 100.00% <0.00%> (ø) |
|
... and 3 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 57989a2...414f844. Read the comment docs.
If it's useful code more or less looks like:
const { getAvailableScripts } = require('nps/dist/bin-utils');
const config = require('package-scripts');
const markdownReplacements = [
[/\*/g, '\\*'],
[/_/g, '\\_'],
[/-/g, '\\-'],
[/\+/g, '\\+'],
[/=/g, '\\='],
[/#/g, '\\#'],
[/`/g, '\\`'],
[/~/g, '\\~'],
[/&/g, '&'],
[/\|/g, '\\|'],
[/\(/g, '\\('],
[/\)/g, '\\)'],
[/\[/g, '\\['],
[/\]/g, '\\]'],
[/</g, '<'],
[/>/g, '>'],
[/(\d+)\./g, '$1\\.'],
];
const escapeMarkdown = (text = '') =>
markdownReplacements.reduce(
(search, replacement) => search.replace(replacement[0], replacement[1]),
text
);
function codeEscape(script = '') {
script = script.replace(/\n/g, '<br/>');
return `<code>${escapeMarkdown(script)}</code>`;
}
function markdownTable({ scripts, options }) {
const availableScripts = getAvailableScripts(scripts).filter((script) => !script.hiddenFromHelp);
const header = `| Name | Description | Script |`;
const separator = `| -- | -- | -- |`;
const rows = availableScripts.map(
({ name, description, script }) =>
`| \`${escapeMarkdown(name)}\` | ${escapeMarkdown(description)} | ${codeEscape(script)} |`
);
return [header, separator, ...rows].join('\n');
}
In order to export a markdown table version of the
nps
output, it's much easier to leverage this function vs copy/pasting it.What:
Why:
How:
Checklist: