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:
parent
cac7db2d19
commit
b33912b7cc
2 changed files with 24 additions and 0 deletions
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue