How to use the npmlog.stream function in npmlog

To help you get started, we’ve selected a few npmlog 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 commercetools / nodejs / packages / price-exporter / src / cli.js View on Github external
})
    rl.on('error', reject)
    rl.on('line', line => {
      rl.close()
      resolve(line.split(_args.delimiter))
    })
  })

const resolveCredentials = _args => {
  if (_args.accessToken) return Promise.resolve({})
  return getCredentials(_args.projectKey)
}

// If the stdout is used for a data output, save all logs to a log file.
if (args.output === process.stdout)
  npmlog.stream = fs.createWriteStream(args.logFile)
else npmlog.stream = process.stdout

// Register error listener
args.output.on('error', errorHandler)

let csvHeaders
getHeaders(args)
  .then(csvHeadersfromInput => {
    csvHeaders = csvHeadersfromInput
    return resolveCredentials(args)
  })
  .then(credentials => {
    const apiConfig = {
      host: args.authUrl,
      apiUrl: args.apiUrl,
      projectKey: args.projectKey,
github nullivex / nodist / bin / node_modules / npm / lib / npm.js View on Github external
npmconf.load(cli, builtin, function (er, conf) {
      if (er === conf) er = null

      npm.config = conf

      var color = conf.get("color")

      log.level = conf.get("loglevel")
      log.heading = "npm"
      log.stream = conf.get("logstream")
      switch (color) {
        case "always": log.enableColor(); break
        case false: log.disableColor(); break
      }
      log.resume()

      if (er) return cb(er)

      // see if we need to color normal output
      switch (color) {
        case "always":
          npm.color = true
          break
        case false:
          npm.color = false
          break
github angelozerr / tern.java / eclipse / tern.eclipse.ide.server.nodejs.embed.linux.gtk.x86 / nodejs / node-v0.10.22-linux-x86 / lib / node_modules / npm / lib / npm.js View on Github external
npmconf.load(cli, builtin, function (er, conf) {
      if (er === conf) er = null

      npm.config = conf

      var color = conf.get("color")

      log.level = conf.get("loglevel")
      log.heading = "npm"
      log.stream = conf.get("logstream")
      switch (color) {
        case "always": log.enableColor(); break
        case false: log.disableColor(); break
      }
      log.resume()

      if (er) return cb(er)

      // see if we need to color normal output
      switch (color) {
        case "always":
          npm.color = true
          break
        case false:
          npm.color = false
          break
github commercetools / nodejs / packages / csv-parser-price / src / cli.js View on Github external
// print errors to stderr if we use stdout for data output
  // if we save data to output file errors are already logged by npmlog
  if (Array.isArray(errors)) errors.forEach(logError)
  else logError(errors)

  process.exitCode = 1
}

const resolveCredentials = _args => {
  if (_args.accessToken) return Promise.resolve({})
  return getCredentials(_args.projectKey)
}

// If the stdout is used for a data output, save all logs to a log file.
if (args.outputFile === process.stdout)
  npmlog.stream = fs.createWriteStream(args.logFile)

// Register error listener
args.outputFile.on('error', errorHandler)

resolveCredentials(args)
  .then(
    credentials =>
      new CsvParserPrice({
        apiConfig: {
          host: args.authUrl,
          apiUrl: args.apiUrl,
          projectKey: args.projectKey,
          credentials,
        },
        accessToken: args.accessToken,
        logger: {
github marklagendijk / WinLess / WinLess / node_modules / npm / lib / npm.js View on Github external
npmconf.load(cli, builtin, function (er, conf) {
      if (er === conf) er = null

      npm.config = conf

      var color = conf.get("color")

      log.level = conf.get("loglevel")
      log.heading = "npm"
      log.stream = conf.get("logstream")
      switch (color) {
        case "always": log.enableColor(); break
        case false: log.disableColor(); break
      }
      log.resume()

      if (er) return cb(er)

      // see if we need to color normal output
      switch (color) {
        case "always":
          npm.color = true
          break
        case false:
          npm.color = false
          break
github testem / testem / lib / api.js View on Github external
configureLogging() {
    let debug = this.config.get('debug');
    if (debug) {
      log.stream = fs.createWriteStream(debug);
    } else {
      let fakeStream = new EventEmitter();
      fakeStream.write = () => {};
      log.stream = fakeStream;
    }
  }
github testem / testem / tests / utils / browser-args_tests.js View on Github external
'use strict';

const browserArgs = require('../../lib/utils/browser-args');
const expect = require('chai').expect;
const log = require('npmlog');

const EventEmitter = require('events').EventEmitter;
const fakeStream = new EventEmitter();

fakeStream.write = function() {};
log.stream = fakeStream;

function createKnownBrowsers() {
  return [{
    name: 'Chrome',
    args: function() {
      return [
        '--testem',
        'http://localhost/'
      ];
    }
  }, {
    name: 'Firefox',
    args: [
      '--testem',
      'http://localhost/'
    ]
github commercetools / nodejs / packages / discount-code-generator / src / cli.js View on Github external
.coerce('output', arg => {
    if (arg === 'stdout') {
      npmlog.stream = fs.createWriteStream('discountCodeGenerator.log')
      return process.stdout
    }
    if (arg.match(/\.json$/i) || arg.match(/\.csv$/i))
      return fs.createWriteStream(String(arg))

    throw new Error('Invalid output file format. Must be CSV or JSON')
  })
  .option('delimiter', {
github NewsUKArchive / dextrose / src / logger.js View on Github external
info: (fileName, textToLog) => {
    log.stream = process.stdout;
    log.prefixStyle = { fg: 'green', bg: 'black' };
    log.info(`[${fileName}] :`, textToLog);
  },
  verbose: (fileName, textToLog) => {
github commercetools / nodejs / packages / csv-parser-discount-code / src / cli.js View on Github external
.on('error', error => {
      npmlog.stream = process.stderr
      errorHandler(error)
    })
    .on('finish', () => {