mirror of https://github.com/actions/toolkit
parent
c5f27c3c1b
commit
9bf86bb363
|
@ -12,22 +12,25 @@ export function debug(message: string): void
|
||||||
export function warning(message: string): void
|
export function warning(message: string): void
|
||||||
export function error(message: string): void
|
export function error(message: string): void
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for exportVariable options
|
|
||||||
*/
|
|
||||||
export interface ExportOptions {
|
|
||||||
/** Optional. Whether the variable should be marked as secret (will be masked from logs). Defaults to false */
|
|
||||||
isSecret?: bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets env variable for this action and future actions in the job
|
* sets env variable for this action and future actions in the job
|
||||||
*
|
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val the value of the variable
|
* @param val the value of the variable
|
||||||
* @param options optional. See ExportOptions.
|
|
||||||
*/
|
*/
|
||||||
export function exportVariable(name: string, val: string, options?: ExportOptions): void
|
export function exportVariable(name: string, val: string): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* exports the variable and registers a secret which will get masked from logs
|
||||||
|
* @param name the name of the variable to set
|
||||||
|
* @param val value of the secret
|
||||||
|
*/
|
||||||
|
export function exportSecret(name: string, val: string): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepends inputPath to the PATH
|
||||||
|
* @param inputPath
|
||||||
|
*/
|
||||||
|
export function addPath(inputPath: string): void
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for getInput options
|
* Interface for getInput options
|
||||||
|
@ -197,10 +200,4 @@ export async function cacheDir(sourceDir: string, tool: string, version: string,
|
||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
export function find(toolName: string, versionSpec: string, arch?: string): string
|
export function find(toolName: string, versionSpec: string, arch?: string): string
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
export function addPath(inputPath: string): void
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {ExitCode} from '@actions/exit'
|
import {ExitCode} from '@actions/exit'
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
|
import * as path from 'path'
|
||||||
import * as core from '../src/core'
|
import * as core from '../src/core'
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
|
@ -11,6 +12,7 @@ const testEnvVars = {
|
||||||
'my secret': '',
|
'my secret': '',
|
||||||
'special char secret \r\n];': '',
|
'special char secret \r\n];': '',
|
||||||
'my secret2': '',
|
'my secret2': '',
|
||||||
|
PATH: `path1${path.delimiter}path2`,
|
||||||
|
|
||||||
// Set inputs
|
// Set inputs
|
||||||
INPUT_MY_INPUT: 'val',
|
INPUT_MY_INPUT: 'val',
|
||||||
|
@ -78,6 +80,14 @@ describe('@actions/core', () => {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('prependPath produces the correct commands and sets the env', () => {
|
||||||
|
core.addPath('myPath')
|
||||||
|
expect(process.env['PATH']).toBe(
|
||||||
|
`myPath${path.delimiter}path1${path.delimiter}path2`
|
||||||
|
)
|
||||||
|
assertWriteCalls([`##[add-path]myPath${os.EOL}`])
|
||||||
|
})
|
||||||
|
|
||||||
it('getInput gets non-required input', () => {
|
it('getInput gets non-required input', () => {
|
||||||
expect(core.getInput('my input')).toBe('val')
|
expect(core.getInput('my input')).toBe('val')
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import {ExitCode} from '@actions/exit'
|
import {ExitCode} from '@actions/exit'
|
||||||
import {issue, issueCommand} from './command'
|
import {issue, issueCommand} from './command'
|
||||||
|
|
||||||
|
import * as path from 'path'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for getInput options
|
* Interface for getInput options
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +35,15 @@ export function exportSecret(name: string, val: string): void {
|
||||||
issueCommand('set-secret', {}, val)
|
issueCommand('set-secret', {}, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepends inputPath to the PATH (for this action and future actions)
|
||||||
|
* @param inputPath
|
||||||
|
*/
|
||||||
|
export function addPath(inputPath: string): void {
|
||||||
|
issueCommand('add-path', {}, inputPath)
|
||||||
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input. The value is also trimmed.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue