clients/js: Add command to start aptos validator

commit-id:ab3ef326
This commit is contained in:
Csongor Kiss 2022-08-28 15:52:29 +02:00
parent 7fbffe424d
commit c4f4652f35
1 changed files with 29 additions and 0 deletions

29
clients/js/cmds/start.ts Normal file
View File

@ -0,0 +1,29 @@
import yargs from "yargs";
import { spawnSync } from 'child_process';
import { config } from '../config';
exports.command = 'start-validator';
exports.desc = 'Start a local validator';
exports.builder = function(y: typeof yargs) {
return y.option("validator-args", {
alias: "a",
type: "string",
array: true,
default: [],
describe: "Additional args to validator",
}).command("aptos", "Start a local aptos validator", (yargs) => {
}, (argv) => {
const dir = `${config.wormholeDir}/aptos`;
// check if aptos is installed
const aptos = spawnSync("aptos", ["--version"]);
if (aptos.status !== 0) {
console.error("aptos is not installed. Please install aptos and try again.");
console.error(`See ${dir}/README.md for instructions.`);
process.exit(1);
}
const args = argv['validator-args'].map(a => `"${a}"`).join(" ");
const cmd = `cd ${dir} && aptos node run-local-testnet --with-faucet --force-restart --assume-yes ${args}`;
console.log("\x1b[33m%s\x1b[0m", cmd);
spawnSync(cmd, { shell: true, stdio: "inherit" });
}).strict().demandCommand();
}