baggywrinkle
Advanced tools
Comparing version 1.5.1 to 1.6.0
51
index.js
@@ -0,1 +1,3 @@ | ||
const _ = require('@sailshq/lodash'); | ||
const rttc = require('rttc'); | ||
const machineAsAction = require('machine-as-action'); | ||
@@ -6,2 +8,51 @@ const statuses = require('statuses'); | ||
// Set up global sails mock. | ||
global.sails = { | ||
config: { | ||
appPath: process.cwd(), | ||
}, | ||
log: { | ||
info: console.log, | ||
debug: console.log, | ||
warn: console.log, | ||
error: console.log, | ||
verbose: process.env.sails_log__level==='verbose' || process.env.sails_log__level==='silly' ? console.log : () => {}, | ||
silly: process.env.sails_log__level==='silly' ? console.log : () => {}, | ||
blank: () => {} | ||
}, | ||
on: () => {}, | ||
once: () => {} | ||
}; | ||
// Parse env vars into config. | ||
const prefix = 'sails_'; | ||
// Cache the prefix length so we don't have to keep looking it up. | ||
const l = prefix.length; | ||
// Loop through the env vars, looking for ones with the right prefix. | ||
_.each(process.env, function(val, key) { | ||
// If this var's name has the right prefix... | ||
if((key.indexOf(prefix)) === 0) { | ||
// Replace double-underscores with dots, to work with Lodash _.set(). | ||
var keypath = key.substring(l).replace(/__/g,'.'); | ||
// Attempt to parse the value as JSON. | ||
try { | ||
val = rttc.parseHuman(val, 'json'); | ||
} | ||
// If that doesn't work, humanize the value without providing a schema. | ||
catch(unusedErr) { | ||
val = rttc.parseHuman(val); | ||
} | ||
// Override the current value at this keypath in `conf` (which currently contains | ||
// the string value of the env var) with the now (possibly) humanized value. | ||
_.set(sails.config, keypath, val); | ||
} | ||
}); | ||
// Allow both `(optsOrMachineDefOrMachine, options)` and `(optsOrMachineDefOrMachine, bootstrap, teardown)` signatures. | ||
@@ -8,0 +59,0 @@ let options = typeof bootstrap === 'object' ? bootstrap : { |
{ | ||
"name": "baggywrinkle", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "Run a machine from an AWS Lambda function.", | ||
@@ -12,5 +12,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"@sailshq/lodash": "^3.10.2", | ||
"machine-as-action": "^9.0.2", | ||
"rttc": "^9.8.2", | ||
"statuses": "1.4.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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
25182
228
4
5
+ Added@sailshq/lodash@^3.10.2
+ Addedrttc@^9.8.2