Sin descripción

mkdirp 731B

123456789101112131415161718192021222324252627282930313233
  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. })();