From 5a21f234cf2353d0dd54cb75284e6ed79d209600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20von=20der=20Gr=C3=BCn?= Date: Tue, 9 Nov 2021 22:26:23 +0100 Subject: [PATCH] refactor: hide implementation of build & run (#1188) This makes build and run modules more closed by avoiding to expose internals via the resolved promise value. Both modules' main exports previously returned a promise that resolved to a subrocess spawn result. Now these promises resolve to undefined. The public API methods that return these promises did not document a specific promise return value, just when the promise would resolve or reject. Thus, this change is not breaking. --- bin/templates/scripts/cordova/lib/build.js | 4 +++- bin/templates/scripts/cordova/lib/run.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js index db43ccc395..cfe1e6ec51 100644 --- a/bin/templates/scripts/cordova/lib/build.js +++ b/bin/templates/scripts/cordova/lib/build.js @@ -87,6 +87,7 @@ function getDefaultSimulatorTarget () { }); } +/** @returns {Promise} */ module.exports.run = buildOpts => { let emulatorTarget = ''; const projectPath = path.join(__dirname, '..', '..'); @@ -263,7 +264,8 @@ module.exports.run = buildOpts => { return fs.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8') .then(checkSystemRuby) .then(packageArchive); - }); + }) + .then(() => {}); // resolve to undefined }; /** diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js index b6d849ea71..1918edfe1c 100644 --- a/bin/templates/scripts/cordova/lib/run.js +++ b/bin/templates/scripts/cordova/lib/run.js @@ -30,6 +30,7 @@ const fs = require('fs-extra'); const cordovaPath = path.join(__dirname, '..'); const projectPath = path.join(__dirname, '..', '..'); +/** @returns {Promise} */ module.exports.run = runOptions => { // Validate args if (runOptions.device && runOptions.emulator) { @@ -108,7 +109,8 @@ module.exports.run = runOptions => { } else { return module.exports.deployToSim(appPath, runOptions.target); } - }); + }) + .then(() => {}); // resolve to undefined }; module.exports.filterSupportedArgs = filterSupportedArgs;