@coderich/util
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "@coderich/util", | ||
"main": "src/index.js", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "access": "public" |
@@ -0,1 +1,3 @@ | ||
const FS = require('fs'); | ||
const Path = require('path'); | ||
const ChildProcess = require('child_process'); | ||
@@ -16,2 +18,3 @@ const ObjectId = require('bson-objectid'); | ||
exports.timeout = ms => new Promise((resolve) => { setTimeout(resolve, ms); }); | ||
exports.ucFirst = string => string.charAt(0).toUpperCase() + string.slice(1); | ||
@@ -131,1 +134,20 @@ exports.filterRe = (arr, fn) => { | ||
}; | ||
exports.requireDir = (dir) => { | ||
const data = {}; | ||
dir = Path.resolve(dir); | ||
FS.readdirSync(dir).forEach((filename) => { | ||
const { name } = Path.parse(filename); | ||
const path = `${dir}/${filename}`; | ||
const stat = FS.statSync(path); | ||
if (stat && stat.isDirectory()) { | ||
data[name] = exports.requireDir(path); | ||
} else if (path.includes('.js')) { | ||
data[name] = require(path); // eslint-disable-line import/no-dynamic-require, global-require | ||
} | ||
}); | ||
return data; | ||
}; |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
5470
127
3