Skip to content

Nicolab/node-spawn-rmrf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spawn-rmrf

Actual version published on NPM

Removes recursively with rm -rf ./file/path (spawned), then executes a callback on end (optional).

Quick start

Install

npm install spawn-rmrf

Usage

var rmrf = require('spawn-rmrf');

Basic

rmrf('/path/to/remove');

With a callback (when done)

rmrf('/path/to/remove', function(code) {
  console.log('Finished with code ' + code);
});

With Gulp

// async
gulp.task('clean', function(done){
  rmrf('/path/to/remove', done);
});

ChildProcess events

rmrf function launches a child process (spawn) and returns a ChildProcess instance, see the Node.js doc (spawn) for more details.

So you can use event listeners:

var rm = rmrf('/path/to/remove');

rm.stdout.on('data', function (data) {
  console.log('stdout: ', data);
});

rm.stderr.on('data', function (data) {
  console.log('stderr: ', data);
});

rm.on('close', function (code) {
  console.log('rmrf exited with code ' + code);
});

Testing

spawn-rmrf is tested with Unit.js and Mocha. Unit.js is a powerful and intuitive unit testing framework for javascript.

License

MIT (c) 2013, Nicolas Tallefourtane.

Author

Nicolas Tallefourtane - Nicolab.net
Nicolas Talle
Make a donation via Paypal

About

Removes recursively with rm -rf `./file/path` (spawned).

Resources

License

Stars

Watchers

Forks

Packages

No packages published