Skip to content

Commit 757faf5

Browse files
author
devAxeon
committed
Copy progress unused + remove works with files and remove given folder (used to only empty it)
1 parent 3c17633 commit 757faf5

File tree

9 files changed

+3169
-59
lines changed

9 files changed

+3169
-59
lines changed

app-test/package-lock.json

Lines changed: 3094 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-test/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"author": "Apache Cordova Team",
1414
"license": "Apache-2.0",
1515
"dependencies": {
16-
"cordova-android": "^8.1.0"
16+
"cordova": "^9.0.0",
17+
"cordova-android": "^8.1.0",
18+
"cordova-plugin-file": "^6.0.2",
19+
"cordova-plugin-whitelist": "1"
1720
},
1821
"devDependencies": {
1922
"cordova-plugin-whitelist": "^1.3.4"

dist/cordova-shell.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cordova-shell.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare module shell {
2828
* @param source
2929
* @param dest
3030
*/
31-
const copy: (source: string, dest: string, progressCallback?: (percent: any) => void) => Promise<ShellEntry>;
31+
const copy: (source: string, dest: string) => Promise<ShellEntry>;
3232
/**
3333
* Download a remote file to a local folder
3434
* @param url

dist/node-shell.js

Lines changed: 33 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node-shell.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node/copy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {ShellEntry} from "../ShellEntry";
22
const fs = require('fs-extra')
33
import {ls} from "./ls";
44

5-
export function copy(source : string, dest : string, progressCallback? : (percent) => void) : Promise<ShellEntry> {
5+
export function copy(source : string, dest : string) : Promise<ShellEntry> {
66
return new Promise((resolve, reject) => {
77
fs.copy(source, dest, err => {
88
if(err) {
@@ -15,4 +15,4 @@ export function copy(source : string, dest : string, progressCallback? : (percen
1515
}
1616
})
1717
});
18-
}
18+
}

src/node/remove.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
const fs = require('fs-extra')
1+
const fs = require('fs-extra');
22
import * as log from './log';
33

44
export const remove = (path : string) : Promise<void> => {
55
return new Promise((resolve, reject) => {
6-
fs.emptyDir(path, err => {
7-
if(err) {
6+
fs.lstat(path, (err, stat) => {
7+
if(err){
88
reject(err);
9-
}
10-
else {
11-
log.info('removed ' + path);
12-
resolve();
9+
} else {
10+
if(stat.isFile()){
11+
fs.remove(path, err => {
12+
if(err) {
13+
reject(err);
14+
} else {
15+
log.info('removed ' + path);
16+
resolve();
17+
}
18+
});
19+
} else {
20+
fs.emptyDir(path, err => {
21+
if(err) {
22+
reject(err);
23+
}
24+
else {
25+
fs.rmdir(path, (err) => {
26+
if(err) {
27+
reject(err);
28+
} else {
29+
log.info('removed ' + path);
30+
resolve();
31+
}
32+
});
33+
}
34+
});
35+
}
1336
}
1437
});
1538
});
16-
};
39+
};

0 commit comments

Comments
 (0)