Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should correctly generate documentation for available commands with settings links', () => {
expect(markdownCommands('roc-test', mockConfig, mockMetaConfig, '/docs/Settings.md', []))
/* eslint-disable max-len */
.toEqual(redent(trimNewlines(`
# Commands for \`roc-test\`
## General Information
All commands can be called with some additional options as can be seen below.
### General options
| Name | Description | Required |
| --------------- | ------------------------------------------------------------------------------------------------------------- | -------- |
| -c, --config | Path to configuration file, will default to roc.config.js in current working directory. | No |
| -d, --directory | Path to working directory, will default to the current working directory. Can be either absolute or relative. | No |
| -h, --help | Output usage information. | No |
| -V, --verbose | Enable verbose mode. | No |
| -v, --version | Output version number. | No |
## Commands
return (...args) => {
const message = args[0];
const title = isString(args[1]) ? args[1] : args[2];
const error = isString(args[1]) ? args[2] : args[1];
const log = console[level]; // eslint-disable-line
log(
`${labels[level](label, title)}
${trimNewlines(redent(message, 2))}${redent(getError(error), 2)}
${getFromWhere(name, version, error)}`
);
if (level === 'error') {
process.exit(process.exitCode || 1); // eslint-disable-line
}
};
};
function buildGroup(cli, command, commandData, allSettingGroups, printGroup, parents, level) {
const rows = [];
rows.push(`##${'#'.repeat(level)} ${command}`);
if (commandData.__meta && commandData.__meta.name) {
rows.push(`__${commandData.__meta.name}__`);
rows.push('');
}
rows.push(`\`\`\`\n${cli} ${parents.concat(command).join(' ')} \n\`\`\``);
if (commandData.__meta) {
// If we have a markdown property we will use that over description
if (commandData.__meta.markdown) {
rows.push(redent(trimNewlines(commandData.__meta.markdown)), '');
} else if (commandData.__meta.description) {
rows.push(commandData.__meta.description, '');
}
}
rows.push('');
return rows;
}
sortedActions.forEach((currentAction) => {
rows.push(`### ${createHookName(currentAction.hook, currentAction.action)}`);
if (currentAction.description) {
rows.push('', redent(trimNewlines(currentAction.description)));
}
rows.push('');
// eslint-disable-next-line
rows.push('__Connects to extension:__ ' +
(currentAction.extension ?
`\`${currentAction.extension}\`` :
'Not specified')
+ ' '
);
// eslint-disable-next-line
rows.push('__Connects to hook:__ ' +
(currentAction.hook ?
`\`${currentAction.hook}\`` :
function getMessage(
matcher,
expectedLabel,
expectedValue,
receivedLabel,
receivedValue,
) {
return [
`${matcher}\n`,
`${expectedLabel}:\n${expectedColor(redent(display(expectedValue), 2))}`,
`${receivedLabel}:\n${receivedColor(redent(display(receivedValue), 2))}`,
].join('\n')
}
body: this.command.options.toString()
})
}
if (!this.root.options.isEmpty()) {
help += formatSection({
title: 'GLOBAL OPTIONS',
body: this.root.options.toString()
})
}
for (const h of this.root.extraHelps) {
help += formatSection(h)
}
return redent(help, 2)
}
packages.forEach((pkg) => {
rows.push(`### ${pkg.name} — [v${pkg.version}](https://www.npmjs.com/package/${pkg.name})`);
const description = isFunction(pkg.description) ?
pkg.description(commandObject, extension) :
pkg.description && trimNewlines(redent(pkg.description));
if (description) {
rows.push(description);
}
rows.push('');
});
} else {
packages.forEach((pkg) => {
rows.push(`#### ${pkg.name} — [v${pkg.version}](https://www.npmjs.com/package/${pkg.name})`);
const description = isFunction(pkg.description) ?
pkg.description(commandObject, extension) :
pkg.description && trimNewlines(redent(pkg.description));
rows.push(description, '');
});
} else {
export function feedbackMessage(label, message, location) {
const locationMessage = location ?
`\n${chalk.gray('Occurred in ' + chalk.underline(location))}\n` :
'';
return label +
redent(`
${message}
${locationMessage}`, 2);
}