1
0
Fork 0

Run npm run lint -- --fix

pull/4/head
Jonathan Clem 2019-05-21 10:51:22 -04:00
parent 4090b77772
commit 451bb07ec4
No known key found for this signature in database
GPG Key ID: 48C5B22E9FD6E80F
2 changed files with 25 additions and 25 deletions

View File

@ -13,7 +13,7 @@ import process = require('process')
*/ */
export function exportVariable(name: string, val: string) { export function exportVariable(name: string, val: string) {
process.env[name] = val process.env[name] = val
intm._issueCommand('set-variable', {name: name}, val) intm._issueCommand('set-variable', {name}, val)
} }
/** /**
@ -34,8 +34,8 @@ export function setSecret(name: string, val: string) {
* @returns string * @returns string
*/ */
export function getInput(name: string, options?: im.InputOptions): string { export function getInput(name: string, options?: im.InputOptions): string {
let val: string = const val: string =
process.env['INPUT_' + name.replace(' ', '_').toUpperCase()] || '' process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`) throw new Error(`Input required and not supplied: ${name}`)
} }

View File

@ -15,7 +15,7 @@ export function _issueCommand(
properties: any, properties: any,
message: string message: string
) { ) {
var cmd = new _Command(command, properties, message) const cmd = new _Command(command, properties, message)
_writeLine(cmd.toString()) _writeLine(cmd.toString())
} }
@ -23,7 +23,7 @@ export function _issue(name: string, message: string) {
_issueCommand(name, {}, message) _issueCommand(name, {}, message)
} }
let CMD_PREFIX = '##[' const CMD_PREFIX = '##['
export class _Command { export class _Command {
constructor(command: string, properties: any, message: string) { constructor(command: string, properties: any, message: string) {
@ -41,17 +41,17 @@ export class _Command {
public properties: any public properties: any
public toString() { public toString() {
var cmdStr = CMD_PREFIX + this.command let cmdStr = CMD_PREFIX + this.command
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' ' cmdStr += ' '
for (var key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
var val = this.properties[key] const val = this.properties[key]
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += key + '=' + escape('' + (val || '')) + ';' cmdStr += `${key}=${escape(`${val || ''}`)};`
} }
} }
} }
@ -61,7 +61,7 @@ export class _Command {
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
let message: string = '' + (this.message || '') const message: string = `${this.message || ''}`
cmdStr += escapedata(message) cmdStr += escapedata(message)
return cmdStr return cmdStr
@ -69,41 +69,41 @@ export class _Command {
} }
export function _commandFromString(commandLine: string) { export function _commandFromString(commandLine: string) {
var preLen = CMD_PREFIX.length const preLen = CMD_PREFIX.length
var lbPos = commandLine.indexOf('[') const lbPos = commandLine.indexOf('[')
var rbPos = commandLine.indexOf(']') const rbPos = commandLine.indexOf(']')
if (lbPos == -1 || rbPos == -1 || rbPos - lbPos < 3) { if (lbPos == -1 || rbPos == -1 || rbPos - lbPos < 3) {
throw new Error('Invalid command brackets') throw new Error('Invalid command brackets')
} }
var cmdInfo = commandLine.substring(lbPos + 1, rbPos) const cmdInfo = commandLine.substring(lbPos + 1, rbPos)
var spaceIdx = cmdInfo.indexOf(' ') const spaceIdx = cmdInfo.indexOf(' ')
var command = cmdInfo let command = cmdInfo
var properties: {[key: string]: string} = {} const properties: {[key: string]: string} = {}
if (spaceIdx > 0) { if (spaceIdx > 0) {
command = cmdInfo.trim().substring(0, spaceIdx) command = cmdInfo.trim().substring(0, spaceIdx)
var propSection = cmdInfo.trim().substring(spaceIdx + 1) const propSection = cmdInfo.trim().substring(spaceIdx + 1)
var propLines: string[] = propSection.split(';') const propLines: string[] = propSection.split(';')
propLines.forEach(function(propLine: string) { propLines.forEach(function(propLine: string) {
propLine = propLine.trim() propLine = propLine.trim()
if (propLine.length > 0) { if (propLine.length > 0) {
var eqIndex = propLine.indexOf('=') const eqIndex = propLine.indexOf('=')
if (eqIndex == -1) { if (eqIndex == -1) {
throw new Error('Invalid property: ' + propLine) throw new Error(`Invalid property: ${propLine}`)
} }
var key: string = propLine.substring(0, eqIndex) const key: string = propLine.substring(0, eqIndex)
var val: string = propLine.substring(eqIndex + 1) const val: string = propLine.substring(eqIndex + 1)
properties[key] = unescape(val) properties[key] = unescape(val)
} }
}) })
} }
let msg: string = unescapedata(commandLine.substring(rbPos + 1)) const msg: string = unescapedata(commandLine.substring(rbPos + 1))
var cmd = new _Command(command, properties, msg) const cmd = new _Command(command, properties, msg)
return cmd return cmd
} }