1
|
#!/usr/bin/env node
|
2
|
|
3
|
var mkdirp = require('../');
|
4
|
var minimist = require('minimist');
|
5
|
var fs = require('fs');
|
6
|
|
7
|
var argv = minimist(process.argv.slice(2), {
|
8
|
alias: { m: 'mode', h: 'help' },
|
9
|
string: [ 'mode' ]
|
10
|
});
|
11
|
if (argv.help) {
|
12
|
fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
|
13
|
return;
|
14
|
}
|
15
|
|
16
|
var paths = argv._.slice();
|
17
|
var 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
|
})();
|