Skip to content

Commit

Permalink
Fixed precondition checks for whatsnew and mapping files, to fix issu…
Browse files Browse the repository at this point in the history
…es outlined in #2
  • Loading branch information
r0adkll committed Dec 12, 2019
1 parent 3e0a7f8 commit b6496ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/edits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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-(?<local>.*-.*)/.compile();
let localizedReleaseNotes = [];
Expand All @@ -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}`);
Expand Down
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC
}

async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise<LocalizedText[] | undefined> {
if (whatsNewDir != undefined) {
if (whatsNewDir != undefined && whatsNewDir.length > 0) {
const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value));
const pattern = /whatsnew-(?<local>.*-.*)/.compile();

Expand Down Expand Up @@ -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}`);
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand Down

0 comments on commit b6496ac

Please sign in to comment.