machinepack-process
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -61,9 +61,4 @@ module.exports = { | ||
// Import `lodash`. | ||
var _ = require('@sailshq/lodash'); | ||
// Import `machinepack-json`. | ||
var MPJSON = require('machinepack-json'); | ||
// First, determine the string to escape. | ||
@@ -79,3 +74,49 @@ var stringToEscape; | ||
try { | ||
stringToEscape = MPJSON.stringifySafe({value:inputs.value}).execSync(); | ||
// This was modified by @mikermcneil from @isaacs' json-stringify-safe | ||
// (see https://github.com/isaacs/json-stringify-safe/commit/02cfafd45f06d076ac4bf0dd28be6738a07a72f9#diff-c3fcfbed30e93682746088e2ce1a4a24) | ||
function serializer() { | ||
var stack = []; | ||
var keys = []; | ||
// Function to replace circular references with a string describing the reference. | ||
// Used by the custom stringify function below. | ||
var cycleReplacer = function(key, value) { | ||
if (stack[0] === value) { | ||
return '[Circular ~]'; | ||
} | ||
return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']'; | ||
}; | ||
// Return a custom stringify function to be used as the second argument | ||
// to the native JSON.stringify. | ||
return function(key, value) { | ||
if (stack.length > 0) { | ||
var thisPos = stack.indexOf(this); | ||
~thisPos ? stack.splice(thisPos + 1) : stack.push(this); | ||
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key); | ||
if (~stack.indexOf(value)) { | ||
value = cycleReplacer.call(this, key, value); | ||
} | ||
} | ||
else { | ||
stack.push(value); | ||
} | ||
// Do some advanced serialization | ||
if (_.isError(value)){ | ||
value = value.stack; | ||
} | ||
else if (_.isRegExp(value)){ | ||
value = value.toString(); | ||
} | ||
else if (_.isFunction(value)){ | ||
value = value.toString(); | ||
} | ||
return value; | ||
}; | ||
} | ||
// Serialize the string. | ||
stringToEscape = JSON.stringify(inputs.value, serializer()); | ||
} catch (e) { | ||
@@ -82,0 +123,0 @@ // If we couldn't stringify the value, exit through the `couldNotSerialize` exit. |
@@ -25,3 +25,2 @@ module.exports = { | ||
// Import `open` and `openBrowserAndNavigateToUrl`. | ||
var openBrowserAndNavigateToUrl = require('opn'); | ||
@@ -32,3 +31,2 @@ | ||
// Return through the `success` exit. | ||
return exits.success(); | ||
@@ -35,0 +33,0 @@ } |
{ | ||
"name": "machinepack-process", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Work with child procs and the running process.", | ||
@@ -20,3 +20,2 @@ "scripts": { | ||
"machine": "^15.0.0-23", | ||
"machinepack-json": "^2.0.0", | ||
"opn": "5.3.0" | ||
@@ -23,0 +22,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
52725
3
739
3
- Removedmachinepack-json@^2.0.0
- Removedconvert-to-ecmascript-compatible-varname@0.1.4(transitive)
- Removeddebug@3.1.0(transitive)
- Removedlodash@2.4.23.8.0(transitive)
- Removedlodash.iserror@3.1.1(transitive)
- Removedlodash.isfunction@3.0.8(transitive)
- Removedlodash.isregexp@3.0.5(transitive)
- Removedmachine@12.1.1(transitive)
- Removedmachinepack-json@2.0.1(transitive)
- Removedms@2.0.0(transitive)
- Removedobject-hash@0.3.0(transitive)
- Removedrttc@9.3.4(transitive)
- Removedswitchback@2.0.0(transitive)