Skip to content

Commit

Permalink
feat: add windowsVerbatimArguments in some exec (#591)
Browse files Browse the repository at this point in the history
* feat: add shell: true for Win

* pass windowsVerbatimArguments
  • Loading branch information
KazuCocoa committed Mar 6, 2022
1 parent 1a3147c commit 926b598
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/tools/apk-signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ apkSigningMethods.executeApksigner = async function executeApksigner (args = [])
log.debug(`Starting apksigner: ${util.quote(fullCmd)}`);
// It is necessary to specify CWD explicitly; see https://github.com/appium/appium/issues/14724#issuecomment-737446715
const {stdout, stderr} = await exec(fullCmd[0], fullCmd.slice(1), {
cwd: path.dirname(apkSignerJar)
cwd: path.dirname(apkSignerJar), windowsVerbatimArguments: system.isWindows()
});
for (let [name, stream] of [['stdout', stdout], ['stderr', stderr]]) {
if (!_.trim(stream)) {
Expand Down Expand Up @@ -132,7 +132,7 @@ apkSigningMethods.signWithCustomCert = async function signWithCustomCert (apk) {
'-keypass', this.keyPassword,
apk, this.keyAlias];
log.debug(`Starting jarsigner: ${util.quote(fullCmd)}`);
await exec(fullCmd[0], fullCmd.slice(1));
await exec(fullCmd[0], fullCmd.slice(1), { windowsVerbatimArguments: system.isWindows() });
} catch (e) {
throw new Error(`Could not sign with custom certificate. ` +
`Original error: ${e.stderr || e.message}`);
Expand Down Expand Up @@ -337,7 +337,7 @@ apkSigningMethods.getKeystoreHash = async function getKeystoreHash () {
];
log.info(`Running '${keytool}' with arguments: ${util.quote(args)}`);
try {
const {stdout} = await exec(keytool, args);
const {stdout} = await exec(keytool, args, { windowsVerbatimArguments: system.isWindows() });
const result = {};
for (const hashName of [SHA512, SHA256, SHA1, MD5]) {
const hashRe = new RegExp(`^\\s*${hashName}:\\s*([a-f0-9:]+)`, 'mi');
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
"@babel/eslint-parser": "^7.16.3",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-promise": "^6.0.0",
"gulp": "^4.0.0",
"mocha": "^9.0.0",
"mocha-junit-reporter": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion test/unit/apk-signing-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe('signing', withMocks({teen_process, helpers, adb, appiumSupport, fs, te
'-keystore', keystorePath,
'-storepass', password,
'-keypass', password,
selendroidTestApp, keyAlias])
selendroidTestApp, keyAlias],
{ windowsVerbatimArguments: appiumSupport.system.isWindows() })
.returns({});
mocks.helpers.expects('getJavaHome')
.returns(javaHome);
Expand Down

0 comments on commit 926b598

Please sign in to comment.