How to use the hook-std.stderr function in hook-std

To help you get started, we’ve selected a few hook-std 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 gulp-sourcemaps / gulp-sourcemaps / test / init.js View on Github external
test('init: should output an error message if debug option is set and sourceContent is missing', function(t) {

    var file = makeFile();
    file.contents = new Buffer(sourceContent + '\n//# sourceMappingURL=helloworld4.js.map');

    var history = [];
    console.log('HOOKING');
    var unhook = hookStd.stderr(function(s) {
      history.push(s);
    });
    var pipeline = sourcemaps.init({loadMaps: true});

    pipeline.on('data', function() {
      unhook();
      var hasRegex =  function(regex){
        return function(s){
          return regex.test(s);
        };
      };
      console.log(history);
      t.ok(
        history.some(
          hasRegex(/No source content for "missingfile". Loading from file./g)), 'should log missing source content');
      t.ok(history.some(hasRegex(/source file not found: /g)), 'should warn about missing file');
github gulp-sourcemaps / gulp-sourcemaps / test / write.js View on Github external
test('write: should output an error message if debug option is set and sourceContent is missing', function(t) {
    var file = makeFile();
    file.sourceMap.sources[0] += '.invalid';
    delete file.sourceMap.sourcesContent;

    var history = [];
    var unhook = hookStd.stderr(function(s) {
      history.push(s);
    });
    var pipeline = sourcemaps.write();

    var hasRegex =  function(regex){
      return function(s){
        return regex.test(s);
      };
    };
    pipeline.on('data', function() {
      unhook();
      console.log(JSON.stringify(history));
      t.ok(history.some(hasRegex(/No source content for "helloworld.js.invalid". Loading from file./g)), 'should log missing source content');
      t.ok(history.some(hasRegex(/source file not found: /g)), 'should warn about missing file');
      t.end();
    }).write(file);
github heroku / heroku-cli-util / test / spinner.js View on Github external
function readOutput (spinner, callback) {
    let out = ''

    const unhook = hookStd.stderr({silent: true}, output => {
      out += output
    })

    spinner.start()
    spinner.stop()
    unhook()

    callback(out)
  }
github sindresorhus / alfy / index.js View on Github external
alfy.debug = getEnv('debug') === '1';

alfy.icon = {
	get: getIcon,
	info: getIcon('ToolbarInfo'),
	warning: getIcon('AlertCautionIcon'),
	error: getIcon('AlertStopIcon'),
	alert: getIcon('Actions'),
	like: getIcon('ToolbarFavoritesIcon'),
	delete: getIcon('ToolbarDeleteIcon')
};

loudRejection(alfy.error);
process.on('uncaughtException', alfy.error);
hookStd.stderr(alfy.error);

hook-std

Hook and modify stdout and stderr

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular hook-std functions