const { Client } = require("ssh2")
const chalk = require("chalk")
const conn = new Client()

conn
	.on("ready", () => {
		conn.exec("cd /home/yanyalin/  \n./hip r devops", (err, stream) => {
			if (err) {
				console.log(chalk.red("发布失败.\n"))
				throw err
			} else {
				stream
					.on("close", (code, signal) => {
						console.log(chalk.green("Success! 成功发布到测试服务器! \n"))
						conn.end()
					})
					.on("data", data => {
						console.log("STDOUT: " + data)
					})
			}
		})
	})
	.connect({
		host: "10.0.90.29",
		port: 22,
		username: "wangzhao",
		password: "b7c7f4eb668185e7f2e33bf62b59ba3b"
	})
