unity-builder/src/model/system.js

45 lines
860 B
JavaScript
Raw Normal View History

2020-05-01 11:57:42 +00:00
import * as core from '@actions/core';
import { exec } from '@actions/exec';
class System {
static async run(command, arguments_, options) {
let result = '';
let error = '';
2020-05-01 11:57:42 +00:00
let debug = '';
const listeners = {
stdout: (dataBuffer) => {
result += dataBuffer.toString();
},
stderr: (dataBuffer) => {
error += dataBuffer.toString();
},
debug: (dataString) => {
2020-05-01 11:57:42 +00:00
debug += dataString.toString();
},
};
2020-05-01 13:50:28 +00:00
const exitCode = await exec(command, arguments_, { silent: true, listeners, ...options });
2020-05-01 11:57:42 +00:00
if (debug !== '') {
core.debug(debug);
}
if (result !== '') {
core.info(result);
}
if (exitCode !== 0) {
throw new Error(error);
}
2020-05-01 11:57:42 +00:00
if (error !== '') {
core.warning(error);
}
return result;
}
}
export default System;