Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
recursive-fs
Advanced tools
The recursive-fs npm package provides utilities for performing recursive file system operations such as copying and removing directories and their contents.
Recursive Copy
This feature allows you to recursively copy the contents of one directory to another. The code sample demonstrates how to use the `copy` method to copy all files and subdirectories from 'sourceDir' to 'destDir'.
const rfs = require('recursive-fs');
rfs.copy('sourceDir', 'destDir', function(err) {
if (err) {
console.error('Error during copy:', err);
} else {
console.log('Copy completed successfully');
}
});
Recursive Remove
This feature allows you to recursively remove a directory and all of its contents. The code sample demonstrates how to use the `remove` method to delete 'targetDir' and all files and subdirectories within it.
const rfs = require('recursive-fs');
rfs.remove('targetDir', function(err) {
if (err) {
console.error('Error during remove:', err);
} else {
console.log('Remove completed successfully');
}
});
fs-extra is a popular package that extends the native Node.js fs module with additional methods, including recursive file system operations. It provides similar functionality to recursive-fs, such as copying and removing directories recursively, but also includes many other useful file system utilities.
rimraf is a package specifically designed for deep deletion of directories. It provides a simple and efficient way to recursively remove directories and their contents, similar to the remove functionality in recursive-fs.
ncp (Node Copy) is a package focused on copying files and directories. It supports recursive copying and provides similar functionality to the copy feature in recursive-fs. However, it is more specialized and does not include other file system operations.
Asynchronous Recursive File System Operations
var rfs = require('recursive-fs')
var path = require('path')
var directory = path.resolve(process.cwd(), process.argv[2])
;(async () => {
try {
var {dirs, files} = await rfs.read(directory)
console.log(dirs)
console.log(files)
console.log('DONE!')
}
catch (err) {
console.error(err)
}
})()
var rfs = require('recursive-fs')
var path = require('path')
var directory = path.resolve(process.cwd(), process.argv[2])
;(async () => {
try {
await rfs.remove(directory)
console.log('DONE!')
}
catch (err) {
console.error(err)
}
})()
var rfs = require('recursive-fs')
var path = require('path')
var source = path.resolve(process.cwd(), process.argv[2])
var destination = path.resolve(process.cwd(), process.argv[3])
;(async () => {
try {
await rfs.copy(source, destination)
console.log('DONE!')
}
catch (err) {
console.error(err)
}
})()
npx recursive-copy 'path/to/source/directory' 'path/to/destination/directory'
npx recursive-delete 'path/to/directory'
FAQs
Asynchronous recursive file system operations
The npm package recursive-fs receives a total of 151,967 weekly downloads. As such, recursive-fs popularity was classified as popular.
We found that recursive-fs 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.