@kubiklabs/wasmkit
Version:
Wasmkit is a development environment to compile, deploy, test, run cosmwasm contracts on different networks.
30 lines (29 loc) • 1.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stopLocalnet = void 0;
const chalk_1 = __importDefault(require("chalk"));
const child_process_1 = require("child_process");
const errors_1 = require("../../internal/core/errors");
const errors_list_1 = require("../../internal/core/errors-list");
async function stopLocalnet(nodeType, env) {
// read the wasmkit config for "localnetwork"
if (!(nodeType in env.config.localnetworks)) {
throw new errors_1.WasmkitError(errors_list_1.ERRORS.NETWORK.UNKNOWN_LOCAL_NETWORK, {
nodeType: nodeType
});
}
const containerExists = (0, child_process_1.execSync)(`docker ps -a -q -f name=${nodeType}`);
// stop the node container if running
if (containerExists.toString().length > 0) {
console.log(`Stopping container: ${chalk_1.default.green(nodeType)}`);
// stop container if running
(0, child_process_1.execSync)(`docker container stop ${nodeType}`);
}
else {
console.log(`Container not running: ${chalk_1.default.green(nodeType)}`);
}
}
exports.stopLocalnet = stopLocalnet;