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