How to use the indent-string function in indent-string

To help you get started, we’ve selected a few indent-string 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 prisma / photonjs / packages / photon / src / runtime / utils / common.ts View on Github external
export function stringifyInputType(input: string | DMMF.InputType | DMMF.Enum, greenKeys: boolean = false): string {
  if (typeof input === 'string') {
    return input
  }
  if ((input as DMMF.Enum).values) {
    return `enum ${input.name} {\n${indent((input as DMMF.Enum).values.join(', '), 2)}\n}`
  } else {
    const body = indent(
      (input as DMMF.InputType).fields // TS doesn't discriminate based on existence of fields properly
        .map(arg => {
          const argInputType = arg.inputType[0]
          const key = `${arg.name}`
          const str = `${greenKeys ? chalk.green(key) : key}${argInputType.isRequired ? '' : '?'}: ${chalk.white(
            arg.inputType
              .map(argType =>
                argIsInputType(argType.type)
                  ? argType.type.name
                  : wrapWithList(stringifyGraphQLType(argType.type), argType.isList),
              )
              .join(' | '),
          )}`
          if (!argInputType.isRequired) {
github DevExpress / testcafe / src / reporters / xunit.js View on Github external
if (hasErr) {
            this.report += ' >\n';
            this.report += indentString('\n', ' ', 4);
            this.report += indentString(' {
                err = escapeHtml(this._formatError(err, `${idx + 1}) `));

                this.report += '\n';
                this.report += wordwrap(err, 6, this.LINE_WIDTH);
                this.report += '\n';
            });

            this.report += indentString(']]>\n', ' ', 4);
            this.report += indentString('\n', ' ', 4);
            this.report += indentString('\n', ' ', 2);
        }
        else
            this.report += ' />\n';
    }
github cacjs / cac / src / index.js View on Github external
const optionsTable = table(Object.keys(this.options).map(option => [
      chalk.yellow(prefixedOption(option, this.aliasOptions)),
      chalk.dim(this.options[option].description),
      showDefaultValue(this.options[option].defaultValue)
    ]))

    const commandsTable = table(Object.keys(this.aliasCommands).map(command => {
      const alias = this.aliasCommands[command]
      return [
        chalk.yellow(`${command}${alias ? `, ${alias}` : ''}`),
        chalk.dim(this.commands[command].description)
      ]
    }))

    const examples = this.examples.length > 0 ?
      `\nExamples:\n\n${indent(this.examples.join('\n'), 2)}\n` :
      ''

    let help = `${this.pkg.description ? `\n${this.pkg.description}\n` : ''}
Usage: ${this.cliUsage}
${examples}
Commands:

${indent(commandsTable, 2)}

Options:

${indent(optionsTable, 2)}
`

    console.log(indent(help, 2))
    process.exit(0)
github jxnblk / layouts / src / editor.js View on Github external
const formatCode = (code, mode) => {
  switch (mode) {
    case 'theme-ui':
      return [
        '/** @jsx jsx */',
        `import { jsx } from 'theme-ui'`,
        '',
        'export default props =>',
        indent(code, 2),
      ].join('\n')
      break
    case 'emotion':
      return [
        '/** @jsx jsx */',
        `import { jsx } from '@emotion/core'`,
        '',
        'export default props =>',
        indent(code, 2),
      ].join('\n')
      break
    case 'rebass':
    default:
      return [
        `import React from 'react'`,
        `import { Box, Flex } from 'rebass'`,
github gattigaga / schemator / src / plugins / laravel / helpers.js View on Github external
export const modelTemplate = (modelName, fields) => {
  const indent = 12;
  const stringifiedFields = fields.map(field => `'${field}'`).join(",\n");
  const fillable = indentString(stringifiedFields, indent).trim();

  return stripIndent(String.raw)`
github expo / xdl / src / detach / IosPodsTools.js View on Github external
function _renderUnversionedReactNativeDependency(options, sdkVersion) {
  let sdkMajorVersion = parseSdkMajorVersion(sdkVersion);
  if (sdkMajorVersion < 21) {
    return indentString(
      `
${_renderUnversionedReactDependency(options, sdkVersion)}
${_renderUnversionedYogaDependency(options, sdkVersion)}
`,
      2
    );
  } else {
    const glogLibraryName = sdkMajorVersion < 26 ? 'GLog' : 'glog';
    return indentString(
      `
${_renderUnversionedReactDependency(options, sdkVersion)}
${_renderUnversionedYogaDependency(options, sdkVersion)}
${_renderUnversionedThirdPartyDependency(
        'DoubleConversion',
        path.join('third-party-podspecs', 'DoubleConversion.podspec'),
        options
github antvis / gatsby-theme-antv / @antv / gatsby-theme-antv / site / components / Toolbar.tsx View on Github external
function getHtmlCodeTemplate() {
    const { htmlCodeTemplate = '', container = '' } = playground;
    const insertCssMatcher = /insertCss\(`\s*(.*)\s*`\);/;
    const code = replaceFetchUrl(sourceCode)
      .replace(/import\s+.*\s+from\s+['"].*['"];?/g, '')
      .replace(insertCssMatcher, '')
      .replace(/^\s+|\s+$/g, '');
    let result = htmlCodeTemplate
      .replace('{{code}}', indentString(code, 4))
      .replace('{{title}}', exmapleTitle || 'example');
    const customStyles = sourceCode.match(insertCssMatcher);
    if (customStyles && customStyles[1]) {
      result = result.replace(
        '',
        `  <style>\n${indentString(
          customStyles[1],
          4,
        )}\n    </style>\n  `,
      );
    }
    if (container) {
      result = result.replace(
        '',
        `\n${indentString(container, 4)}`,
      );
github expo / expo-cli / packages / xdl / src / detach / IosPodsTools.js View on Github external
function _renderUnversionedUniversalModuleDependency(podName, path, sdkVersion) {
  const attributes = {
    path,
  };
  return `pod '${podName}',
${indentString(_renderDependencyAttributes(attributes), 2)}`;
}
github prisma / photonjs / packages / photon-generate / src / runtime / query.ts View on Github external
public _toString(value: ArgValue, key: string): string {
    if (value instanceof Args) {
      return `${key}: {
${indent(value.toString(), 2)}
}`
    }

    if (Array.isArray(value)) {
      const isScalar = !(value as any[]).some(v => typeof v === 'object')
      return `${key}: [${isScalar ? '' : '\n'}${indent(
        (value as any[])
          .map(nestedValue => {
            if (nestedValue instanceof Args) {
              return `{\n${indent(nestedValue.toString(), tab)}\n}`
            }
            return stringify(nestedValue, null, 2, this.isEnum)
          })
          .join(`,${isScalar ? ' ' : '\n'}`),
        isScalar ? 0 : tab,
      )}${isScalar ? '' : '\n'}]`
    }

    return `${key}: ${stringify(value, null, 2, this.isEnum)}`
  }
  public toString() {

indent-string

Indent each line in a string

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular indent-string functions