
Product
Rust Support in Socket Is Now Generally Available
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.
mirror-folder
Advanced tools
Small module to mirror a folder to another folder. Supports live mode as well.
Small module to mirror a folder to another folder.
Supports watch mode as well where it will continuously watch the src folder and mirror new entries as they are created/removed.
npm install mirror-folder
var mirror = require('mirror-folder')
mirror('/Users/maf/cool-stuff', '/Users/maf/cool-stuff-mirror', function (err) {
if (err) throw err
console.log('Folder was mirrored')
})
var progress = mirror(src, dst, [options], [callback])Mirror src to dst. Returns a progress event emitter.
Options include:
{
watch: false, // keep watching the src and mirror new entries,
dereference: false, // dereference any symlinks
equals: fun // optional function to determine if two entries are the same, see below
ignore: null // optional function to ignore file paths on src or dest
}
The equals function looks like this:
function equals (src, dst, cb) {
console.log('src.name', src.name)
console.log('src.stat', src.stat)
console.log('dst.name', dst.name)
console.log('dst.stat', dst.stat)
cb(null, true) // callback with true if they are the same or false if not
}
Per default the equals function will check if mtime is larger on the src entry or if the size is different
The ignore function looks like this:
function ignore (file) {
// ignore any files with secret in them
if (file.indexOf('secret') > -1) return true
return false
}
If you are using a custom fs module (like graceful-fs) you can pass that in
with the src or dst like this:
mirror({name: '/Users/maf/cool-stuff', fs: customFs}, {name: '/Users/maf/cool-stuff-mirror', fs: anotherFs})
progress.on('put', src, dst)Emitted when a file/folder is copied from the src to the dst folder.
progress.on('put-data', data)Emitted when a file chunk is read from the src.
progress.on('put-end', src, dst)Emitted at the end of a write stream (files only).
progress.on('del', dst)Emitted when a file/folder is deleted from the dst folder.
progress.on('end')Emitted when the mirror ends (not emitted in watch mode). The mirror callback is called when this event is emitted as well
progress.on('error', err)Emitted when a critical error happens. If you pass a mirror callback you don't need to listen for this.
progress.destory()Stop mirroring files. If using watch mode, close the file watcher.
MIT
FAQs
Small module to mirror a folder to another folder. Supports live mode as well.
The npm package mirror-folder receives a total of 180 weekly downloads. As such, mirror-folder popularity was classified as not popular.
We found that mirror-folder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.