How to use get-stdin - 10 common examples

To help you get started, we’ve selected a few get-stdin 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 flow-typed / flow-typed / definitions / npm / get-stdin_v5.x.x / test_get-stdin_v5.x.x.js View on Github external
import getStdin from 'get-stdin';

getStdin().then((str: string) => {});
getStdin.buffer().then((str: Buffer) => {});

// $ExpectError
(getStdin(): number);

// $ExpectError
(getStdin.buffer(): number);
github flow-typed / flow-typed / definitions / npm / get-stdin_v5.x.x / test_get-stdin_v5.x.x.js View on Github external
import getStdin from 'get-stdin';

getStdin().then((str: string) => {});
getStdin.buffer().then((str: Buffer) => {});

// $ExpectError
(getStdin(): number);

// $ExpectError
(getStdin.buffer(): number);
github itgalaxy / imagemin-power-cli / cli.js View on Github external
if (cli.flags.recursive) {
    optionsBase.recursive = cli.flags.recursive;
}

if (cli.flags.ignoreErrors) {
    optionsBase.ignoreErrors = cli.flags.ignoreErrors;
}

if (cli.input.length > 0) {
    run(cli.input, cli.flags).catch(error => {
        console.error(error.stack); // eslint-disable-line no-console
        process.exit(1); // eslint-disable-line no-process-exit
    });
} else {
    getStdin.buffer().then(buf => run(buf, cli.flags)).catch(error => {
        console.error(error.stack); // eslint-disable-line no-console

        const exitCode = typeof error.code === "number" ? error.code : 1;

        process.exit(exitCode); // eslint-disable-line no-process-exit
    });
}
github pgilad / leasot / src / cli / cli.ts View on Github external
const run = (program: ProgramArgs): void => {
    if (program.args && program.args.length > 0) {
        return parseAndReportFiles(program.args, program);
    }

    if (process.stdin.isTTY) {
        return program.help();
    }

    // data is coming from a pipe
    getStdin()
        .then(function(content: string) {
            const todos = parseContentSync(content, program);
            outputTodos(todos, program);
        })
        .catch(function(e) {
            console.error(e);
            process.exit(1);
        });
};
github mikberg / codenamer / src / cli.js View on Github external
letters. Adjust variance like 'n10/2'.
      c       Word class. Restrict this word to a word class:
                        - J for adjective
                        - N for noun
                        - R for adverb
                        - V for verb
      a               Alliterate (word rhyme) up to and including this word,
                      e.g. allow 'cheshire cat' but not 'cheshire dog'.

    Examples
      $ cat myfile.txt | codenamer
      $ curl -s https://en.wikipedia.org/wiki/Batman | codenamer
      $ curl -s https://en.wikipedia.org/wiki/Batman | codenamer --format pa-a,n15
`, minimistOptions);

getStdin().then(input => {
  if (!input) {
    /* eslint no-console:0 */
    console.error('ERR: No input given');
    console.log(cli.help);
    process.exit(0);
  }

  const options = Object.assign({}, defaults, cli.flags);
  const output = codenamer(options.format.split('-'), input, options.count);

  console.log(output.map(code => code.join('-')).join('\n'));
});
github kubernetes-sigs / cluster-api-provider-digitalocean / vendor / github.com / googleapis / gnostic / linters / node / gnostic-lint-operations / gnostic-lint-operations.js View on Github external
// import libraries
const protobuf = require("protobufjs")
const getStdin = require('get-stdin')

// import messages
const root = protobuf.Root.fromJSON(require("./bundle.json"))
const Request = root.lookupType("gnostic.plugin.v1.Request")
const Response = root.lookupType("gnostic.plugin.v1.Response")
const Document = root.lookupType("openapi.v2.Document")

getStdin.buffer().then(buffer => {
	const request = Request.decode(buffer)
	messages = []
	for (var j in request.models) {
		const m = request.models[j]
		if (m.type_url == "openapi.v2.Document") {
			const openapi2 = Document.decode(m.value)
			const paths = openapi2.paths.path
			for (var i in paths) {
				const path = paths[i]
				//console.error('path %s\n\n', path.name)
				const getOperation = path.value.get
				if (getOperation && getOperation.operationId == "") {
					messages.push({level:3, code:"NOOPERATIONID", text:"No operation id.", keys:["paths", path.name, "get"]})
				}
				const postOperation = path.value.post
				if (postOperation && postOperation.operationId == "") {
github gajus / canonical / src / bin / commands / fixCommand.js View on Github external
const handleStdin = (argv) => {
    /* eslint-disable no-unused-expressions */
    yargs
    /* eslint-enable */
        .demand(0, 0)
        .argv;

    getStdin()
        .then((stdin) => {
            const result = fixText(stdin, {
                syntax: argv.syntax
            });

            /* eslint-disable no-console */
            console.log(result);
            /* eslint-enable */
        });
};
github twardoch / svgop / src / svgop-pkg.js View on Github external
'removeScriptElement',
                    'removeStyleElement',
                    'removeTitle',
                    'removeUnknownsAndDefaults',
                    'removeUnusedNS',
                    'removeUselessDefs',
                    'removeUselessStrokeAndFill',
                    'removeViewBox',
                    'removeXMLNS',
                    'removeXMLProcInst',
                    'sortAttrs'
                ]
        }
    );

getStdin.buffer().then(data => {
//    var doctype = data.toString('utf8').substring(0,5); 
//    if (doctype == "%PDF-") { 
//        pdfjsLib.getDocument({
//                data: data.buffer,
//                nativeImageDecoderSupport: pdfjsLib.NativeImageDecoding.DISPLAY
//            }).then(function (pdfDoc) {
//                var lastPromise = Promise.resolve();
//                var loadPage = function (pageNum) {
//                    return pdfDoc.getPage(pageNum).then(function (page) {
//                        var viewport = page.getViewport(1.0);
//                        var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
//                        svgGfx.embedFonts = true;
//                        return page.getOperatorList().then(function (opList) {
//                            return svgGfx.getSVG(opList, viewport).then(function (svg) {
//                                var svgstr = svg.toString().replace(/svg:/g, '');
//                                svgo.optimize(svgstr).then(function(result) {
github gajus / canonical / src / bin / commands / lintCommand.js View on Github external
const handleStdin = (argv) => {
    /* eslint-disable no-unused-expressions */
    yargs
    /* eslint-enable */
        .demand(0, 0)
        .argv;

    getStdin()
        .then((stdin) => {
            const report = lintText(stdin, {
                filePath: argv.filePath,
                syntax: argv.syntax
            });

            outputReport({
                errorCount: report.errorCount,
                results: [
                    report
                ],
                warningCount: report.warningCount
            }, argv.outputFormat);
        });
};
github Jam3 / devtool / test / fixtures / stdin.js View on Github external
require('get-stdin')()
  .then(function (data) {
    process.stdout.write(data.toString(), function () {
      window.close();
    });
  })
  .catch(function (err) {
    process.stdout.write(err.message + '\n', function () {
      process.exit(1);
    });
  });

get-stdin

Get stdin as a string or buffer

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis

Popular get-stdin functions