mirror of https://github.com/actions/toolkit
Match core to spec (still work to do)
parent
5f66339fde
commit
917c389219
|
@ -3,8 +3,28 @@
|
|||
import * as core from '../src/lib'
|
||||
|
||||
describe('@actions/core', () => {
|
||||
it('needs tests', () => {
|
||||
|
||||
it('tests exportVariable', () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it('tests getInput', () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it('tests setFailure', () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it('tests error', () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it('tests warning', () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it('tests debug', () => {
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"actions"
|
||||
],
|
||||
"author": "Bryan MacFarlane <bryanmac@microsoft.com>",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"license": "MIT",
|
||||
"main": "lib/lib.js",
|
||||
"directories": {
|
||||
|
|
|
@ -10,7 +10,7 @@ import os = require('os');
|
|||
*
|
||||
* Examples:
|
||||
* ##[warning]This is the user warning message
|
||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
||||
* ##[set-secret name=mypassword]definitelyNotAPassword!
|
||||
*/
|
||||
export function _issueCommand(command: string, properties: {[key: string]: string}, message: string) {
|
||||
var cmd = new _Command(command, properties, message);
|
||||
|
@ -67,7 +67,6 @@ export class _Command {
|
|||
}
|
||||
|
||||
export function _commandFromString(commandLine: string) {
|
||||
var preLen = CMD_PREFIX.length;
|
||||
var lbPos = commandLine.indexOf('[');
|
||||
var rbPos = commandLine.indexOf(']');
|
||||
if (lbPos == -1 || rbPos == -1 || rbPos - lbPos < 3) {
|
||||
|
|
|
@ -3,33 +3,53 @@ import intm = require('./internal');
|
|||
import process = require('process');
|
||||
|
||||
/**
|
||||
* sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable
|
||||
* Interface for exportVariable options
|
||||
*/
|
||||
export function setVariable(name: string, val: string) {
|
||||
export interface ExportOptions {
|
||||
/** Optional. Whether the variable should be marked as secret (will be masked from logs). Defaults to false */
|
||||
isSecret?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets env variable for this action and future actions in the job
|
||||
*
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable
|
||||
* @param options optional. See ExportOptions.
|
||||
*/
|
||||
export function exportVariable(name: string, val: string, options?: ExportOptions): void {
|
||||
if (options && options.isSecret) {
|
||||
intm._issueCommand('set-secret', {'name': name}, val);
|
||||
}
|
||||
process.env[name] = val;
|
||||
intm._issueCommand('set-variable', {'name': name}, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a variable which will get masked from logs
|
||||
* @param name name of the secret variable
|
||||
* @param val value of the secret variable
|
||||
* Interface for getInput options
|
||||
*/
|
||||
export function setSecret(name: string, val: string) {
|
||||
intm._issueCommand('set-secret', {'name': name}, val);
|
||||
setVariable(name, val);
|
||||
}
|
||||
export interface InputOptions {
|
||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of an input. The value is also trimmed.
|
||||
*
|
||||
* @param name name of the input to get
|
||||
* @param options optional. See InputOptions.
|
||||
* @returns string
|
||||
*/
|
||||
export function getInput(name: string, options?: InputOptions): string | undefined {
|
||||
// TODO - how are we passing in actions inputs?
|
||||
return '';
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Results
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* fail the action
|
||||
* @param message
|
||||
*/
|
||||
export function fail(message: string) {
|
||||
export function setFailure(message: string): void {
|
||||
process.exitCode = im.ExitCode.Failure;
|
||||
error(message);
|
||||
}
|
||||
|
@ -38,19 +58,16 @@ export function fail(message: string) {
|
|||
// Logging Commands
|
||||
// https://github.com/github/dreamlifter/blob/master/docs/actions-model.md#logging-commands
|
||||
//
|
||||
// error and warning issues do not take FileDetails because while possible,
|
||||
// that's typically reserved for the agent and the problem matchers.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
export function addPath(path: string) {
|
||||
intm._issueCommand('add-path', {}, path);
|
||||
}
|
||||
|
||||
export function error(message: string) {
|
||||
intm._issue('error', message);
|
||||
}
|
||||
|
||||
export function warning(message: string) {
|
||||
intm._issue('warning', message);
|
||||
}
|
||||
|
||||
export function debug(message: string): void {
|
||||
intm._issue('debug', message);
|
||||
}
|
Loading…
Reference in New Issue