From e90b8af9304a4911edc50fed3b325f7d2504bdc7 Mon Sep 17 00:00:00 2001 From: Joshua Quick Date: Fri, 20 Mar 2020 14:23:01 -0700 Subject: [PATCH] fix(android): module "clean" shouldn't error if missing "libs" (#11509) - When doing an "appc ti clean" in module folder, now checks if "libs" directory exists before attempting to clean it. * Titanium 9.0.0 no longer generates a "libs" folder. So, this help avoids the error. Co-authored-by: ssekhri --- android/cli/commands/_cleanModule.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/android/cli/commands/_cleanModule.js b/android/cli/commands/_cleanModule.js index cf6a28c2e23..3342be1aa41 100644 --- a/android/cli/commands/_cleanModule.js +++ b/android/cli/commands/_cleanModule.js @@ -17,8 +17,6 @@ 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']; @@ -34,17 +32,20 @@ exports.run = function run(logger, config, cli, finished) { }); // 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)); - } - }); + const libsDir = path.join(projectDir, 'libs'); + if (appc.fs.exists(libsDir)) { + const moduleid = cli.manifest.moduleid; + const arches = fs.readdirSync(libsDir); + 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(); };