How to use redent - 9 common examples

To help you get started, we’ve selected a few redent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocjs / roc / test_old / commands / markdown-commands.js View on Github external
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
github rocjs / roc / src / log / initLogLarge.js View on Github external
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
            }
        };
    };
github rocjs / roc / src / documentation / markdown / commandsToMarkdown.js View on Github external
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;
}
github rocjs / roc / src / documentation / markdown / actionsToMarkdown.js View on Github external
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}\`` :
github testing-library / jest-dom / src / utils.js View on Github external
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')
}
github cacjs / cac / src / Help.ts View on Github external
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)
  }
github rocjs / roc / src / documentation / markdown / extensionsToMarkdown.js View on Github external
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 {
github rocjs / roc / src / documentation / markdown / createReadme.js View on Github external
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 {
github rocjs / roc / src / helpers / style.js View on Github external
export function feedbackMessage(label, message, location) {
    const locationMessage = location ?
        `\n${chalk.gray('Occurred in ' + chalk.underline(location))}\n` :
        '';

    return label +
        redent(`

${message}
${locationMessage}`, 2);
}

redent

Strip redundant indentation and indent the string

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular redent functions