Fixes #15 Add omitBody and omitName

This commit is contained in:
Nick Cipollo
2020-05-25 16:23:42 -04:00
parent 93adae701b
commit 8954a2e764
5 changed files with 87 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
import { GithubError } from "./GithubError"
import {GithubError} from "./GithubError"
export class ErrorMessage {
private error: any
@@ -18,7 +18,7 @@ export class ErrorMessage {
}
}
get status():number {
get status(): number {
return this.error.status
}

View File

@@ -1,16 +1,16 @@
import * as core from '@actions/core';
import { Context } from "@actions/github/lib/context";
import { readFileSync } from 'fs';
import { ArtifactGlobber } from './ArtifactGlobber';
import { Artifact } from './Artifact';
import {Context} from "@actions/github/lib/context";
import {readFileSync} from 'fs';
import {ArtifactGlobber} from './ArtifactGlobber';
import {Artifact} from './Artifact';
export interface Inputs {
readonly allowUpdates: boolean
readonly artifacts: Artifact[]
readonly body: string
readonly body?: string
readonly commit: string
readonly draft: boolean
readonly name: string
readonly name?: string
readonly prerelease: boolean
readonly replacesArtifacts: boolean
readonly tag: string
@@ -47,7 +47,9 @@ export class CoreInputs implements Inputs {
return []
}
get body(): string {
get body(): string | undefined {
if (CoreInputs.omitBody()) return undefined
const body = core.getInput('body')
if (body) {
return body
@@ -61,6 +63,10 @@ export class CoreInputs implements Inputs {
return ''
}
private static omitBody(): boolean {
return core.getInput('omitBody') == 'true'
}
get commit(): string {
return core.getInput('commit')
}
@@ -70,7 +76,9 @@ export class CoreInputs implements Inputs {
return draft == 'true'
}
get name(): string {
get name(): string | undefined {
if (CoreInputs.omitName()) return undefined
const name = core.getInput('name')
if (name) {
return name
@@ -79,6 +87,10 @@ export class CoreInputs implements Inputs {
return this.tag
}
private static omitName(): boolean {
return core.getInput('omitName') == 'true'
}
get prerelease(): boolean {
const preRelease = core.getInput('prerelease')
return preRelease == 'true'
@@ -105,10 +117,10 @@ export class CoreInputs implements Inputs {
}
get token(): string {
return core.getInput('token', { required: true })
return core.getInput('token', {required: true})
}
stringFromFile(path: string): string {
return readFileSync(path, 'utf-8')
}
}
}