/
_cleanModule.js
50 lines (44 loc) 路 1.32 KB
/
_cleanModule.js
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
/**
* Android module clean command.
*
* @module cli/_cleanModule
*
* @copyright
* Copyright (c) 2018 by Appcelerator, Inc. All Rights Reserved.
*
* @license
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
'use strict';
const path = require('path');
const fs = require('fs-extra');
const appc = require('node-appc');
const __ = appc.i18n(__dirname).__;
// TODO Do we need a validate function?
exports.run = function run(logger, config, cli, finished) {
const projectDir = cli.argv['project-dir'];
const toDelete = [ 'build', 'dist', 'java-sources.txt' ];
toDelete.forEach(f => {
const target = path.join(projectDir, f);
if (appc.fs.exists(target)) {
logger.debug(__('Deleting %s', target.cyan));
fs.removeSync(target);
} else {
logger.debug(__('File does not exist %s', target.cyan));
}
});
// remove only the libraries we generate
const moduleid = cli.manifest.moduleid;
const arches = fs.readdirSync(path.join(projectDir, 'libs'));
arches.forEach(arch => {
const target = path.join(projectDir, 'libs', arch, `lib${moduleid}.so`);
if (appc.fs.exists(target)) {
logger.debug(__('Deleting %s', target.cyan));
fs.removeSync(target);
} else {
logger.debug(__('File does not exist %s', target.cyan));
}
});
finished();
};