How to use the @textlint/feature-flag.coreFlags.runningCLI function in @textlint/feature-flag

To help you get started, we’ve selected a few @textlint/feature-flag 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 textlint / textlint / packages / textlint / bin / textlint.js View on Github external
#!/usr/bin/env node
"use strict";
const getStdin = require("get-stdin");
const logSymbols = require("log-symbols");
const useStdIn = process.argv.indexOf("--stdin") > -1;
const isDebug = process.argv.indexOf("--debug") > -1;
if (isDebug) {
    const debug = require("debug");
    debug.enable("textlint*");
}
// must do this initialization *before* other requires in order to work
const cli = require("../lib/textlint/src/cli").cli;
const { coreFlags } = require("@textlint/feature-flag");
// it is for --experimental logger
// update state
coreFlags.runningCLI = !module.parent;

/**
 * show error message for user
 * @param {Error} error
 */
function showError(error) {
    console.error(logSymbols.error, "Error");
    console.error(`${error.message}\n`);
    console.error(logSymbols.error, "Stack trace");
    console.error(error.stack);
}

// Always start as promise
Promise.resolve()
    .then(function() {
        if (useStdIn) {

@textlint/feature-flag

textlint internal feature flag manager.

MIT
Latest version published 21 days ago

Package Health Score

89 / 100
Full package analysis