How to use the process.stdin function in process

To help you get started, we’ve selected a few process 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 salesforce / runway-browser / main.js View on Github external
let repl = function(env) {
  var readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

  let printError = function(error) {
    if (error instanceof errors.Base) { // modeling error
      console.log(`${error}`);
    } else { // JS error
      if (error.stack !== undefined) {
        console.log(`${error.stack}`);
      } else {
        console.log(`${error}`);
      }
    }
  };

  var forgivingLoad = function(input, env) {
github Raynos / itape / context / index.js View on Github external
function reportChildTest(ctx, child) {
    var stdout = child.stdout;

    if (ctx._stdoutFilter) {
        stdout = filterStream(stdout, ctx._stdoutFilter);
    }

    if (ctx._debugMode) {
        process.stdin.pipe(child.stdin);
    }

    stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);

    if (!ctx._debugMode) {
        // TODO. do not write to TAP file for invalid TAP.
        // i.e. a crashed uncaught exception child process.
        var writeStream = fs.createWriteStream(ctx._lastRunTapFile);
        child.stdout.pipe(writeStream, {
            end: false
        });

        child.on('exit', function onErr(code) {
            if (code === 8) {
                writeStream.write('not ok 999 process crashed\n');
github adblockplus / buildtools / webpack_runner.js View on Github external
* License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const path = require("path");
const process = require("process");

const MemoryFS = require("memory-fs");
const webpack = require("webpack");

// We read the configuration from STDIN rather than as an argument to improve
// the output on error. Otherwise the (fairly huge) configuration is printed
// along with the actual error message.
let inputChunks = [];
process.stdin.setEncoding("utf-8");
process.stdin.on("data", chunk => { inputChunks.push(chunk); });
process.stdin.on("end", () =>
{
  let {bundles, extension_path,
       info_module, resolve_paths, aliases} = JSON.parse(inputChunks.join(""));

  // The contents of the info module is passed to us as a string from the Python
  // packager and we pass it through to our custom loader now so it is available
  // at bundle time.
  require("./info-loader").setInfoModule(info_module);

  // Since the cost of starting Node.js and loading all the modules is hugely
  // larger than actually producing bundles we avoid paying it multiple times,
  // instead producing all the bundles in one go.
  let options = [];
  for (let {bundle_name, entry_points} of bundles)
github projectivemotion / i3status-taskwarrior / build / i3status-tw.js View on Github external
full_text: status
    };
    itemlist.unshift(myitem);
    return itemlist;
}
if (process.argv.length > 2 && process.argv[2] == 'json') {
    var list = [];
    append_status(list);
    console.log(JSON.stringify(list[0]));
    process.exit(0);
}
if (Boolean(process.stdin.isTTY)) {
    console.log(get_tw_status());
    process.exit(0);
}
process.stdin.on('readable', function () {
    var d = process.stdin.read();
    if (d === null)
        return;
    var dstr = d.toString();
    //console.log(dstr);
    if (dstr.match(/^,\[.*\]/)) {
        console.log(',' + JSON.stringify(append_status(JSON.parse(dstr.replace(/^,/, '')))));
    }
    else {
        process.stdout.write(dstr);
    }
});
//# sourceMappingURL=i3status-tw.js.map
github uber / lint-trap / lint-stream.js View on Github external
function getBinPathCallback(err, binPath) {
        if (err) {
            return lintMessages.emit('error', err);
        }

        var args = makeArgs(type, files, opts.stdin);
        var lintProcess = spawn(binPath, args);

        if (opts.stdin) {
            process.stdin.pipe(lintProcess.stdin);

            process.stdin.once('end', function onStdinEnd() {
                lintProcess.stdin.end();
            });
        }

        lintProcess.stdout
            .pipe(JSONStream.parse('*'))
            .pipe(severityTransform())
            .pipe(lintMessages)
            .on('error', onError);

        lintProcess.stderr.on('data', onError);

        function onError(linterErr) {
            /*eslint-disable*/
github mdittmer / web-apis / lib / debug.es6.js View on Github external
* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';

const process = require('process');
const readline = require('readline');

require('id-js')();

Error.stackTraceLimit = Infinity;

let rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

let ready = true;
function inspect(f) {
  rl.on('line', cmd => {
    if (cmd === 'q' || cmd === 'quit') {
      rl.close();
      process.exit();
    }
    if (!ready) return;

    ready = false;

    f(() => {
github ftchirou / blink / src / main / interpreter / std / console.js View on Github external
new NativeExpression((context) => {
                process.stdin.pause();

                let prompt = context.store.get(context.environment.find('prompt'));

                let input = readline.questionInt(prompt.get('value'));

                console.log();

                let value = Obj.create(context, Types.Int);

                value.set('value', input);

                process.stdin.resume();

                return value;
            })));
github Ara0n / pyscandl / pyscandl / modules / fetchers / eval.js View on Github external
const process = require('process');

const stream = process.stdin;


f = function(p, a, c, k, e, d) {
    e = function(c) {
        return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
    };
    if (!''.replace(/^/, String)) {
        while (c--) d[e(c)] = k[c] || e(c);
        k = [function(e) {
            return d[e]
        }];
        e = function() {
            return '\\w+'
        };
        c = 1;
    };
github Clickopolis / clickopolis / packages / app / create-component.ts View on Github external
);
    }
}

export const ${name} = connect(
    null,
    null
)(${name}Base);
`;

const exporter = (name) => `export * from './${name}';
`;

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question('Component name:\n> ', answer => {
    askConnected(answer);
});

const askConnected = name => {
    rl.question('Make a connected component? [y/n]\n> ', answer => {
        if (answer === 'y' || answer === 'yes') {
            writeComponent(name, true);
        } else {
            writeComponent(name, false);
        }
    });
};
github backspaces / agentscript / bin / minifyjson.js View on Github external
#!/usr/bin/env node

const process = require('process')
const gis = require('./gis.umd.js')

let data = ''
process.stdin.on('readable', () => {
    while ((chunk = process.stdin.read()) !== null) {
        data += chunk
    }
})

process.stdin.on('end', () => {
    process.stdout.write(processData(data))
})

function processData(data) {
    const json = JSON.parse(data)
    return gis.minify(json)
}