1 | var $;
|
2 |
|
3 | $ = {};
|
4 |
|
5 | $.wrapList = require('../dist/wrapList');
|
6 |
|
7 | $.normalizePathToArray = require('../dist/normalizePathToArray');
|
8 |
|
9 | $.isExisted_ = require('../dist/isExisted_');
|
10 |
|
11 | $.info = require('../dist/info');
|
12 |
|
13 | $.getFilename = require('../dist/getFilename');
|
14 |
|
15 | $.remove_ = require('../dist/remove_');
|
16 |
|
17 | $.copy_ = require('../dist/copy_');
|
18 |
|
19 | module.exports = async function(source) {
|
20 | var filename, i, len, msg, pathBak, ref;
|
21 | msg = `recovered ${$.wrapList(source)}`;
|
22 | ref = $.normalizePathToArray(source);
|
23 | for (i = 0, len = ref.length; i < len; i++) {
|
24 | source = ref[i];
|
25 | pathBak = `${source}.bak`;
|
26 | if (!(await $.isExisted_(pathBak))) {
|
27 | $.info('recover', `'${pathBak}' not found`);
|
28 | continue;
|
29 | }
|
30 | filename = $.getFilename(source);
|
31 | await $.info().silence_(async function() {
|
32 | await $.remove_(source);
|
33 | await $.copy_(pathBak, null, filename);
|
34 | return (await $.remove_(pathBak));
|
35 | });
|
36 | }
|
37 | $.info('recover', msg);
|
38 | return this;
|
39 | };
|