Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
fix: new cordova version wrong path
Browse files Browse the repository at this point in the history
  • Loading branch information
macrozone committed Feb 22, 2019
1 parent 00f7385 commit fe5cfc3
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/build/android_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export const androidInit = ({ config, environment }) => {
}

// kudos to http://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore
const { keystorePW, keyStore, keyname, keyDName } = getKeystoreProps({ config, environment });
const { keystorePW, keyStore, keyname, keyDName } = getKeystoreProps({
config,
environment,
});
const createKeyCommand = shellescape([
'keytool',
'-genkeypair',
Expand All @@ -74,21 +77,31 @@ export const androidInit = ({ config, environment }) => {
};

export const androidPrepareForStore = ({ config, environment }) => {
const { keystorePW, keyStore, keyname } = getKeystoreProps({ config, environment });
const { keystorePW, keyStore, keyname } = getKeystoreProps({
config,
environment,
});
const androidBuildDir = getAndroidBuildDir({ config, environment });
if (!fs.existsSync(androidBuildDir)) {
throw new Error('android build dir does not exist');
}
if (!fs.existsSync(keyStore)) {
throw new Error(`please call android-init ${environment} first`);
}

const now = moment().format('YYYYMMDD-HHmm');

const inFile = `${androidBuildDir}/project/build/outputs/apk/release/android-release-unsigned.apk`;
const inFileOld = `${androidBuildDir}/project/build/outputs/apk/release/android-release-unsigned.apk`;
// file folder has changed in newer cordova versions
const inFileNew = `${androidBuildDir}/project/app/build/outputs/apk/release/app-release-unsigned.apk`;

const inFile = fs.existsSync(inFileNew) ? inFileNew : inFileOld;

const alignFile = `${androidBuildDir}/release-unsigned-aligned.apk`;
if (fs.existsSync(alignFile)) {
fs.unlinkSync(alignFile);
}
//
const zipAlignCommand = shellescape([
getAndroidBuildTool(config, 'zipalign'),
4,
Expand Down Expand Up @@ -118,7 +131,10 @@ export const androidPrepareForStore = ({ config, environment }) => {
outfile,
alignFile,
]);
exec(signCommand, { input: `${keystorePW}\n${keystorePW}`, stdio: ['pipe', 1, 2] });
exec(signCommand, {
input: `${keystorePW}\n${keystorePW}`,
stdio: ['pipe', 1, 2],
});

return outfile;
};

0 comments on commit fe5cfc3

Please sign in to comment.