-
Notifications
You must be signed in to change notification settings - Fork 5
/
removeResCommand.ts
55 lines (47 loc) · 1.61 KB
/
removeResCommand.ts
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
import * as AppCommand from './appCommand';
import * as fs from 'fs';
import * as path from 'path';
exports.command = 'removeres';
exports.describe = '删除app缓存资源'
exports.builder = {
path: {
default: '.',
required: false,
requiresArg: true,
description: 'native项目路径'
}
}
exports.handler = function (argv) {
try {
let cmd = new AppCommand.AppCommand();
let nativeJSONPath = null;
let nativePath = null;
nativePath = AppCommand.AppCommand.getNativePath(argv.path);
nativeJSONPath = AppCommand.AppCommand.getNativeJSONPath(argv.path);
if (!fs.existsSync(nativePath)) {
console.error('错误: 找不到目录 ' + nativePath);
return;
}
if (!fs.existsSync(nativeJSONPath)) {
console.error('错误: 找不到文件 ' + nativeJSONPath + ",无效的native项目路径");
return;
}
let appPath = AppCommand.AppCommand.getAppPath(nativePath, AppCommand.PLATFORM_IOS);
if (fs.existsSync(appPath)) {
cmd.excuteRemoveRes(appPath);
}
appPath = AppCommand.AppCommand.getAppPath(nativePath, AppCommand.PLATFORM_ANDROID_STUDIO);
if (fs.existsSync(appPath)) {
cmd.excuteRemoveRes(appPath);
}
console.debug('请继续......');
}
catch (error) {
if (error.code === 'EPERM') {
console.error('错误:文件已经被使用或被其他程序打开');
}
console.error();
console.error(error.name);
console.error(error.message);
}
}