mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-03-20 13:22:35 +08: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:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user