You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
731 B

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