From b6496ac4e3ce130348503096e0424f2c4e35baf9 Mon Sep 17 00:00:00 2001 From: Drew Heavner Date: Thu, 12 Dec 2019 08:50:26 -0500 Subject: [PATCH] Fixed precondition checks for whatsnew and mapping files, to fix issues outlined in #2 --- lib/edits.js | 4 ++-- lib/main.js | 6 +++--- package.json | 2 +- src/edits.ts | 4 ++-- src/main.ts | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index bd3468fe..7ec03415 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -100,7 +100,7 @@ function trackVersionCode(appEdit, options, versionCode) { } function readLocalizedReleaseNotes(whatsNewDir) { return __awaiter(this, void 0, void 0, function* () { - if (whatsNewDir != undefined) { + if (whatsNewDir != undefined && whatsNewDir.length > 0) { const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value)); const pattern = /whatsnew-(?.*-.*)/.compile(); let localizedReleaseNotes = []; @@ -125,7 +125,7 @@ function readLocalizedReleaseNotes(whatsNewDir) { } function uploadMappingFile(appEdit, versionCode, options) { return __awaiter(this, void 0, void 0, function* () { - if (options.mappingFile != undefined) { + if (options.mappingFile != undefined && options.mappingFile.length > 0) { const mapping = fs_1.readFileSync(options.mappingFile, 'utf-8'); if (mapping != undefined) { core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`); diff --git a/lib/main.js b/lib/main.js index 3ac449f1..22d626e2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -48,11 +48,11 @@ function run() { core.setFailed(`Unable to find release file @ ${releaseFile}`); return; } - if (whatsNewDir != undefined && !fs.existsSync(whatsNewDir)) { + if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) { core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`); return; } - if (mappingFile != undefined && !fs.existsSync(mappingFile)) { + if (mappingFile != undefined && mappingFile.length > 0 && !fs.existsSync(mappingFile)) { core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`); return; } @@ -67,7 +67,7 @@ function run() { whatsNewDir: whatsNewDir, mappingFile: mappingFile }, releaseFile); - core.debug('Finished App Release!'); + console.log(`Finished uploading ${releaseFile} to the Play Store`); } catch (error) { core.setFailed(error.message); diff --git a/package.json b/package.json index 0246f0ef..38cc8dcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "upload-google-play", - "version": "1.0.0", + "version": "1.0.2", "private": true, "description": "Upload an Android release (.apk or .aab) to Google Play Console", "main": "lib/main.js", diff --git a/src/edits.ts b/src/edits.ts index 6de4f83d..1683b309 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -106,7 +106,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC } async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise { - if (whatsNewDir != undefined) { + if (whatsNewDir != undefined && whatsNewDir.length > 0) { const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value)); const pattern = /whatsnew-(?.*-.*)/.compile(); @@ -136,7 +136,7 @@ async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promi } async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options: EditOptions) { - if (options.mappingFile != undefined) { + if (options.mappingFile != undefined && options.mappingFile.length > 0) { const mapping = readFileSync(options.mappingFile, 'utf-8'); if (mapping != undefined) { core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`); diff --git a/src/main.ts b/src/main.ts index 940f6aa2..6085fc97 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,12 +34,12 @@ async function run() { return } - if (whatsNewDir != undefined && !fs.existsSync(whatsNewDir)) { + if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) { core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`); return } - if (mappingFile != undefined && !fs.existsSync(mappingFile)) { + if (mappingFile != undefined && mappingFile.length > 0 && !fs.existsSync(mappingFile)) { core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`); return } @@ -58,7 +58,7 @@ async function run() { mappingFile: mappingFile }, releaseFile); - core.debug('Finished App Release!') + console.log(`Finished uploading ${releaseFile} to the Play Store`) } catch (error) { core.setFailed(error.message) }