Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
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,
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
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
// 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: {
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
configureLogging() {
let debug = this.config.get('debug');
if (debug) {
log.stream = fs.createWriteStream(debug);
} else {
let fakeStream = new EventEmitter();
fakeStream.write = () => {};
log.stream = fakeStream;
}
}
'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/'
]
.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', {
info: (fileName, textToLog) => {
log.stream = process.stdout;
log.prefixStyle = { fg: 'green', bg: 'black' };
log.info(`[${fileName}] :`, textToLog);
},
verbose: (fileName, textToLog) => {
.on('error', error => {
npmlog.stream = process.stderr
errorHandler(error)
})
.on('finish', () => {