12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env node
  2. var mkdirp = require('../');
  3. var minimist = require('minimist');
  4. var fs = require('fs');
  5. var argv = minimist(process.argv.slice(2), {
  6. alias: { m: 'mode', h: 'help' },
  7. string: [ 'mode' ]
  8. });
  9. if (argv.help) {
  10. fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
  11. return;
  12. }
  13. var paths = argv._.slice();
  14. var mode = argv.mode ? parseInt(argv.mode, 8) : undefined;
  15. (function next () {
  16. if (paths.length === 0) return;
  17. var p = paths.shift();
  18. if (mode === undefined) mkdirp(p, cb)
  19. else mkdirp(p, mode, cb)
  20. function cb (err) {
  21. if (err) {
  22. console.error(err.message);
  23. process.exit(1);
  24. }
  25. else next();
  26. }
  27. })();