-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfdel.js
More file actions
69 lines (54 loc) · 2.04 KB
/
fdel.js
File metadata and controls
69 lines (54 loc) · 2.04 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
'use strict';
var lib=require('./lib');
var path=require('path');
var argv=process.argv.slice(2);
var readline = require('readline');
var ProgressBar = require('progress');
//TODO:: properly handler argumetns, its bit danger..
var dir=argv[0];
if(!dir){
console.log('Specify path to delete.');
} else {
dir = path.resolve(process.cwd(), dir);
var rl = readline.createInterface(process.stdin, process.stdout);
rl.question("Are you sure to delete this path? yes/[no]: ", function(answer) {
if(answer === "yes") {
var bar = new ProgressBar('renaming [:bar] :percent :etas', {
total: 100 ,
complete: '=',
incomplete: ' ',
width: 80,
renderThrottle:100
});
var previousProgress=0;
lib.shortRenameEverything(dir,function(progress){
var now=progress-previousProgress;
previousProgress=progress;
bar.tick(now);
if(previousProgress==100){
previousProgress=0;
bar = new ProgressBar('removing [:bar] :percent :etas', {
total: 100 ,
complete: '=',
incomplete: ' ',
width: 80,
renderThrottle:100
});
console.log('removing directory:'+dir);
lib.deleteFolderRecursive(dir,function(progress){
var now=progress-previousProgress;
previousProgress=progress;
bar.tick(now);
if(previousProgress==100) {
console.log('everything done !');
process.exit();
}
});
}
});
} else {
process.exit();
}
});
}