How to use the cli-highlight.highlight function in cli-highlight

To help you get started, we’ve selected a few cli-highlight 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 egodigital / ego-cli / src / commands / devops-items-update / index.ts View on Github external
'Content-type': 'application/json-patch+json',
                                            },
                                            body: JSON.stringify(OPERATIONS),
                                            throwHttpErrors: false,
                                        }
                                    );

                                    if (200 === UPDATE_RESPONSE.statusCode) {
                                        spinner.text = `Work item ${ID} updated`;
                                    } else {
                                        // failed

                                        spinner.fail(`Unexpected response for work item ${ID}: [${UPDATE_RESPONSE.statusCode}] '${UPDATE_RESPONSE.statusMessage}'

${
                                            cliHighlight.highlight(
                                                JSON.stringify(
                                                    JSON.parse(UPDATE_RESPONSE.body), null, 2
                                                ),
                                                {
                                                    "language": "javascript"
                                                }
                                            )
                                            }`);
                                    }
                                } else {
                                    spinner.text = `Work item ${ID} updated`;
                                }
                            }
                        } else {
                            spinner.warn(`Empty result for work item ${ID}!`);
                        }
github egodigital / ego-cli / src / commands / job / index.ts View on Github external
public async showHelp(): Promise {
        writeLine(`Examples:    ego job my-job.js "0 * * * * *"`);
        writeLine(`             ego job my-job  "* */15 * * * *"`);
        writeLine();
        writeLine(`Relative paths will be mapped to the current working directory or the '.ego' subfolder inside the user's home directory.`);
        writeLine();
        writeLine(`It is also possible to run shell scripts (with .sh or .cmd extension).`);
        writeLine();
        writeLine();

        writeLine(`Example script:`);
        writeLine(
            cliHighlight.highlight(
                `
    exports.execute = async (context) => {
        // context  =>  s. https://egodigital.github.io/ego-cli/interfaces/_contracts_.commandexecutecontext.html

        // context.args           =>  List of command line arguments, s. https://www.npmjs.com/package/minimist
        // context.cwd            =>  The full path of the current working directory
        // context.getFullPath()  =>  Returns the full version of a path, based on the value of 'cwd'
        // context.package        =>  The 'package.json' file of the e.GO CLI
        // context.queue          =>  A queue, that only executes 1 action at the same time, s. https://www.npmjs.com/package/p-queue
        // context.require()      =>  Allows to include a NPM module of the e.GO CLI
        // context.values         =>  A key/value pair storage, that is available while the execution
        // context.verbose        =>  Indicates, if script should output additional information or not

        // docker utils, s. https://egodigital.github.io/ego-cli/modules/_docker_.html
        const docker = context.require('./docker');
        // git utils, s. https://egodigital.github.io/ego-cli/modules/_git_.html
github mooyoul / proxyfront / tools / configure.ts View on Github external
filter: Number,
    default: 2592000,
    validate(value) {
      try {
        ow(value, ow.number.greaterThanOrEqual(0).lessThanOrEqual(3153600000));
        return true;
      } catch (e) {
        return e.message;
      }
    },
  }]);

  const config = createConfigYaml({ stage, ...inputs });

  console.log("Generated configuration file contents: \n");
  console.log(highlight(config, { language: "yaml" }));

  const { hasConfirmed } = await inquirer.prompt<{ hasConfirmed: boolean; }>([{
    type: "confirm",
    name: "hasConfirmed",
    message: "Does it looks good?",
    default: true,
  }]);

  if (!hasConfirmed) {
    console.log("\nAborted.");
    return;
  }

  await new Promise(((resolve, reject) => {
    fs.writeFile(CONFIG_FILE_PATH, config, (e) => {
      if (e) { return reject(e); }
github iWinston / typeorm-plus / src / platform / PlatformTools.ts View on Github external
static highlightJson(json: string) {
        return highlight(json, { language: "json" });
    }
github subzerocloud / subzero-cli / src / dashboard.jsx View on Github external
const printLog = data =&gt; highlight(decoder.write(data), {language : 'accesslog'}).replace(/<span class="\&quot;hljs-string\&quot;">/g, '').replace(/&lt;\/span&gt;/g, '');
const printSQL = data =&gt; highlight(decoder.write(data), {language : 'sql'});</span>
github ampproject / amphtml / build-system / single-pass.js View on Github external
function formatSinglePassClosureCompilerError(message) {
  const singlePassJavaInvocationLine = /java -jar[^]*--js_module_root .*?\n/;
  message = message.replace(singlePassJavaInvocationLine, '');
  message = highlight(message, {ignoreIllegals: true});
  message = message.replace(/WARNING/g, colors.yellow('WARNING'));
  message = message.replace(/ERROR/g, colors.red('ERROR'));
  return message;
}
github keplersj / jest-runner-prettier / src / run.js View on Github external
if (isPretty) {
      return pass({
        start,
        end: new Date(),
        test: { path: testPath }
      });
    }

    const formatted = prettier.format(contents, prettierConfig);

    return fail({
      start,
      end: new Date(),
      test: {
        path: testPath,
        errorMessage: diff(highlight(formatted), highlight(contents), {
          expand: false
        })
      }
    });
  });
};
github ampproject / amphtml / build-system / compile / closure-compile.js View on Github external
function formatClosureCompilerError(message) {
  const closurePluginLoggingPrefix = /^.*?gulp-google-closure-compiler.*?: /;
  message = message.replace(closurePluginLoggingPrefix, '');
  message = highlight(message, {ignoreIllegals: true});
  message = message.replace(/WARNING/g, colors.yellow('WARNING'));
  message = message.replace(/ERROR/g, colors.red('ERROR'));
  return message;
}

cli-highlight

Syntax highlighting in your terminal

ISC
Latest version published 4 years ago

Package Health Score

69 / 100
Full package analysis