Search code examples
javascriptnode.jscommand-line-interfacenode-commander

How to run bash with commander.js?


How can I run simple bash commands like rm -rf directory or echo whatever with commander.js?


Solution

  • You can run within your script command like so:

    var program = require('commander');
    
    program
        .version('0.0.1')
        .command('rmdir <dir>')
    

    see full examples at: https://github.com/tj/commander.js/#commands