github-pages-deploy-action/src/execute.ts

29 lines
735 B
TypeScript
Raw Normal View History

2020-01-12 09:26:08 +08:00
import { exec } from "@actions/exec";
let output: string;
2020-01-12 09:26:08 +08:00
/** Wrapper around the GitHub toolkit exec command which returns the output.
* Also allows you to easily toggle the current working directory.
* @param cmd = The command to execute.
* @param cwd - The current working directory.
* @returns - The output from the command.
2020-01-12 09:26:08 +08:00
*/
export async function execute(cmd: string, cwd: string): Promise<any> {
output = "";
2020-01-12 09:26:08 +08:00
await exec(cmd, [], {
// Silences the input unless the INPUT_DEBUG flag is set.
silent: process.env.DEBUG_DEPLOY_ACTION ? false : true,
2020-01-12 09:26:08 +08:00
cwd,
listeners: {
stdout
2020-01-12 09:26:08 +08:00
}
});
return Promise.resolve(output);
}
export function stdout(data: any) {
output += data.toString().trim();
}