testable-utils
Advanced tools
Comparing version 0.3.1 to 0.3.2
var _ = require("lodash"); | ||
var fs = require("fs"); | ||
@@ -19,20 +20,20 @@ function toErrorContent(error) { | ||
function createLog(writeStream) { | ||
function createLog() { | ||
return { | ||
trace: function() { | ||
return sendLog(writeStream, "Trace", Array.prototype.join.call(arguments, '')); | ||
return sendLog("Trace", Array.prototype.join.call(arguments, '')); | ||
}, | ||
debug: function() { | ||
return sendLog(writeStream, "Debug", Array.prototype.join.call(arguments, '')); | ||
return sendLog("Debug", Array.prototype.join.call(arguments, '')); | ||
}, | ||
info: function() { | ||
return sendLog(writeStream, "Info", Array.prototype.join.call(arguments, '')); | ||
return sendLog("Info", Array.prototype.join.call(arguments, '')); | ||
}, | ||
error: function(msg) { | ||
var args = _.map(arguments, function(arg) { return toErrorContent(arg); }); | ||
return sendLog(writeStream, "Error", msg.stack || Array.prototype.join.call(args, '')); | ||
return sendLog("Error", msg.stack || Array.prototype.join.call(args, '')); | ||
}, | ||
fatal: function(msg) { | ||
var args = _.map(arguments, function(arg) { return toErrorContent(arg); }); | ||
return sendLog(writeStream, "Fatal", msg.stack || Array.prototype.join.call(args, '')); | ||
return sendLog("Fatal", msg.stack || Array.prototype.join.call(args, '')); | ||
} | ||
@@ -42,6 +43,6 @@ }; | ||
function sendLog(writeStream, level, msg) { | ||
function sendLog(level, msg) { | ||
return new Promise(function(resolve, reject) { | ||
if (writeStream) { | ||
writeStream.write(JSON.stringify({ | ||
if (process.env.TESTABLE_RESULT_FILE) { | ||
fs.writeFile(process.env.TESTABLE_RESULT_FILE, JSON.stringify({ | ||
type: "Log", | ||
@@ -53,3 +54,3 @@ data: { | ||
} | ||
}) + '\n', 'utf8', resolve); | ||
}) + '\n', { encoding: 'utf8', flag: 'a' }, resolve); | ||
} else { | ||
@@ -56,0 +57,0 @@ console.log('[' + level + '] ' + toErrorContent(msg)); |
@@ -66,5 +66,4 @@ | ||
const doNotWait = isSmokeTest || isLocal; | ||
const writeStream = isLocal ? null : fs.createWriteStream(process.env.TESTABLE_RESULT_FILE, { flags: 'a' }); | ||
const log = createLog(writeStream); | ||
const results = createResults(writeStream, doNotWait); | ||
const log = createLog(); | ||
const results = createResults(doNotWait); | ||
results.current = results('dummy','http://dummy.com'); | ||
@@ -71,0 +70,0 @@ results.toResourceName = function(url) { return url; }; |
const request = require('request'); | ||
const fs = require('fs'); | ||
const _ = require('lodash'); | ||
@@ -64,3 +65,3 @@ | ||
function createResults(writeStream, noRemote) { | ||
function createResults(noRemote) { | ||
const answer = function(resource, url) { | ||
@@ -75,3 +76,3 @@ return { | ||
if (options) | ||
return sendResult(writeStream, { | ||
return sendResult({ | ||
type: 'Timing', | ||
@@ -85,3 +86,3 @@ data: { resource: resource, url: url, namespace: options.namespace, name: options.name, | ||
if (options) | ||
return sendResult(writeStream, { | ||
return sendResult({ | ||
type: 'Counter', | ||
@@ -95,3 +96,3 @@ data: { resource: resource, url: url, namespace: options.namespace, name: options.name, | ||
if (options) | ||
return sendResult(writeStream, { | ||
return sendResult({ | ||
type: 'Histogram', | ||
@@ -182,6 +183,6 @@ data: { resource: resource, url: url,namespace: options.namespace, name: options.name, | ||
function sendResult(writeStream, result) { | ||
function sendResult(result) { | ||
return new Promise(function (resolve, reject) { | ||
if (writeStream) { | ||
writeStream.write(JSON.stringify(result) + '\n', 'utf8', resolve); | ||
if (process.env.TESTABLE_RESULT_FILE) { | ||
fs.writeFile(process.env.TESTABLE_RESULT_FILE, JSON.stringify(result) + '\n', { encoding: 'utf8', flag: 'a' }, resolve); | ||
} else { | ||
@@ -188,0 +189,0 @@ console.log('[Result] ' + JSON.stringify(result, null, '\t')); |
{ | ||
"name": "testable-utils", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Utilities for Testable scripts", | ||
@@ -22,5 +22,5 @@ "author": "Avi Stramer", | ||
"babyparse": "^0.4.6", | ||
"lodash": "^4.17.2", | ||
"lodash": "^4.17.15", | ||
"request": "^2.79.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
711
40985
20
Updatedlodash@^4.17.15