Skip to content

Commit

Permalink
refactor: hide implementation of build & run (apache#1188)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
raphinesse authored and gazben committed Aug 26, 2022
1 parent 8547eef commit 5a21f23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bin/templates/scripts/cordova/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function getDefaultSimulatorTarget () {
});
}

/** @returns {Promise<void>} */
module.exports.run = buildOpts => {
let emulatorTarget = '';
const projectPath = path.join(__dirname, '..', '..');
Expand Down Expand Up @@ -263,7 +264,8 @@ module.exports.run = buildOpts => {
return fs.writeFile(exportOptionsPath, exportOptionsPlist, 'utf-8')
.then(checkSystemRuby)
.then(packageArchive);
});
})
.then(() => {}); // resolve to undefined
};

/**
Expand Down
4 changes: 3 additions & 1 deletion bin/templates/scripts/cordova/lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const fs = require('fs-extra');
const cordovaPath = path.join(__dirname, '..');
const projectPath = path.join(__dirname, '..', '..');

/** @returns {Promise<void>} */
module.exports.run = runOptions => {
// Validate args
if (runOptions.device && runOptions.emulator) {
Expand Down Expand Up @@ -108,7 +109,8 @@ module.exports.run = runOptions => {
} else {
return module.exports.deployToSim(appPath, runOptions.target);
}
});
})
.then(() => {}); // resolve to undefined
};

module.exports.filterSupportedArgs = filterSupportedArgs;
Expand Down

0 comments on commit 5a21f23

Please sign in to comment.