mirror of
https://github.com/docker/login-action.git
synced 2024-11-18 01:55:40 +01:00
6e236fe59d
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
41 lines
844 B
TypeScript
41 lines
844 B
TypeScript
import * as actionsExec from '@actions/exec';
|
|
import {ExecOptions} from '@actions/exec';
|
|
|
|
export interface ExecResult {
|
|
success: boolean;
|
|
stdout: string;
|
|
stderr: string;
|
|
}
|
|
|
|
export const exec = async (
|
|
command: string,
|
|
args: string[] = [],
|
|
silent: boolean,
|
|
stdin?: string
|
|
): Promise<ExecResult> => {
|
|
let stdout: string = '';
|
|
let stderr: string = '';
|
|
|
|
const options: ExecOptions = {
|
|
silent: silent,
|
|
ignoreReturnCode: true,
|
|
input: Buffer.from(stdin || '')
|
|
};
|
|
options.listeners = {
|
|
stdout: (data: Buffer) => {
|
|
stdout += data.toString();
|
|
},
|
|
stderr: (data: Buffer) => {
|
|
stderr += data.toString();
|
|
}
|
|
};
|
|
|
|
const returnCode: number = await actionsExec.exec(command, args, options);
|
|
|
|
return {
|
|
success: returnCode === 0,
|
|
stdout: stdout.trim(),
|
|
stderr: stderr.trim()
|
|
};
|
|
};
|