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 authored and GitHub committed 2021-05-11 13:51:36 -04:00
1 parent ef4cf8f02d
commit 7ebec596c8
2 files changed
+24

No files matched your search

+7
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()
}