mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
23 lines
620 B
TypeScript
23 lines
620 B
TypeScript
import { exec } from "@actions/exec";
|
|
|
|
/** Wrapper around the GitHub toolkit exec command which returns the output.
|
|
* Also allows you to easily toggle the current working directory.
|
|
* @param {String} cmd = The command to execute.
|
|
* @param {String} cwd - The current working directory.
|
|
* @returns {Promise} - The output from the command.
|
|
*/
|
|
export async function execute(cmd: string, cwd: string): Promise<any> {
|
|
let output = "";
|
|
|
|
await exec(cmd, [], {
|
|
cwd,
|
|
listeners: {
|
|
stdout: (data: Buffer) => {
|
|
output += data.toString().trim();
|
|
}
|
|
}
|
|
});
|
|
|
|
return Promise.resolve(output);
|
|
}
|