1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-09 16:43:02 +00:00

Core: Add trimWhitespace to getInput (#802)

* Add option to not trim whitespace from inputs

* Fix typos

* Add doc clarification

* Rename options
This commit is contained in:
Luke Tomlinson 2021-05-11 13:51:36 -04:00 committed by GitHub
parent cac7db2d19
commit b33912b7cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -11,6 +11,9 @@ import * as path from 'path'
export interface InputOptions {
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean
/** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
trimWhitespace?: boolean
}
/**
@ -88,6 +91,10 @@ export function getInput(name: string, options?: InputOptions): string {
throw new Error(`Input required and not supplied: ${name}`)
}
if (options && options.trimWhitespace === false) {
return val
}
return val.trim()
}