mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
26 lines
728 B
JavaScript
26 lines
728 B
JavaScript
const { Buffer } = require('buffer');
|
|
const { exec } = require("child_process");
|
|
|
|
class CliHelper {
|
|
static async listInstances() {
|
|
return await this.execCommand('evernode list');
|
|
}
|
|
|
|
static execCommand(command) {
|
|
return new Promise((resolve, reject) => {
|
|
exec(command, { stdio: 'pipe' }, (err, stdout, stderr) => {
|
|
if (err || stderr) {
|
|
reject(err || stderr);
|
|
return;
|
|
}
|
|
|
|
let message = Buffer.from(stdout).toString();
|
|
resolve(JSON.parse(message.substring(0, message.length - 1))); // Skipping the \n from the result.
|
|
});
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
CliHelper
|
|
} |