
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
import-all-from
Advanced tools
A util helps importing all utils from given directory path
$ npm install import-all-from --save
const importAllFrom = require('import-all-from')
// return an array containing all modules right under given directory
const utils = importAllFrom('/system/absolute/path/to/dest/dir')
utils.forEach(() => {
// do something ...
})
// or
for (const util of utils) {
// do something ...
}
NOTE: Directory path should be an absolute path from system root. For node.js, you can use ___dirname to get absolute path of the directory where current file is located in.
// assume __dirname here refers to '/system/absolute/path/to'
const modules = importAllFrom(__dirname + '/dest/dir')
importAllFrom(path, {
file: {Boolean}, // false for not importing file modules [default: true]
dir: {Boolean}, // false for not importing directory modules [default: true]
regexp: {RegExp} // importing file/directory modules whose name matching regexp [default: undefined]
})
This util makes an easy way to manage structure of test files, you can thus handle each function test with separate file.
describe('unit tests', () => {
// import all tests under specific directory
importAllFrom(__dirname + '/unit-tests')
})
/* unit-tests/unit-test1.js */
describe('unit-test1', ...)
/* unit-tests/unit-test2.js */
describe('unit-test2', ...)
// ...
Perhaps you might have some state handlers / checkers which have same return data format, for better management, you can separate each condition with different modules with this util.
let state
const checkers = importAllFrom(__dirname + '/checkers')
for (const checker of checkers) {
state = checker(...arg)
if (state) { // or satisfied specific condition
// do something ...
}
}
$ npm test
$ npm run test-unit
$ npm run test-integration
MIT
FAQs
A npm package which helps importing all files from given path
We found that import-all-from demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.