-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
38 lines (29 loc) · 777 Bytes
/
cli.js
File metadata and controls
38 lines (29 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { createDir, createFile } = require('./src/bummar');
const yargs = require('yargs').argv;
const srcArg = yargs.d || 'src';
const targetArg = yargs.t || 'test';
function recursivelyReadDir(dirPath) {
fs.readdirSync(dirPath)
.map(item => {
const currentPath = path.join(dirPath, item);
if (fs.lstatSync(currentPath).isDirectory()) {
createDir(currentPath, srcArg, targetArg);
recursivelyReadDir(currentPath);
return;
}
createFile(currentPath, srcArg, targetArg);
});
}
function create() {
if (!fs.existsSync(targetArg)) {
fs.mkdirSync(targetArg);
}
recursivelyReadDir(srcArg);
}
create();
module.exports = {
create
};