mirror of
https://github.com/doocs/md.git
synced 2024-11-28 13:36:32 +08:00
fix(cli): More suitable service detection method (#169)
This commit is contained in:
parent
f0fd26beb0
commit
19d87ce67b
@ -25,20 +25,18 @@ new Promise(async () => {
|
|||||||
}).map(([key, val]) => `${key}=${val}`).join(` `)
|
}).map(([key, val]) => `${key}=${val}`).join(` `)
|
||||||
const cliArg = [handleSpace(`${__dirname}/node_modules/mockm/run.js`), `--log-line`, line]
|
const cliArg = [handleSpace(`${__dirname}/node_modules/mockm/run.js`), `--log-line`, line]
|
||||||
spawn(`node`, cliArg)
|
spawn(`node`, cliArg)
|
||||||
setTimeout(async () => {
|
let oldTime = Date.now()
|
||||||
console.log(``)
|
console.log(`服务启动中...`)
|
||||||
console.log(`doocs/md-cli v${require(`./package.json`).version}`)
|
console.log(`doocs/md-cli v${require(`./package.json`).version}`)
|
||||||
console.log(``)
|
let timer = setInterval(async () => {
|
||||||
try {
|
if((await portIsOk(port)) !== true) { // 服务启动成功
|
||||||
if(await portIsOk(port) === true) {
|
clearInterval(timer)
|
||||||
throw new Error(`服务 ${port} 初始化失败`)
|
|
||||||
}
|
|
||||||
console.log(`服务已启动:`)
|
console.log(`服务已启动:`)
|
||||||
console.log(`打开链接 ${colors.green(`http://127.0.0.1:${port}/md/`)} 即刻使用吧~`)
|
console.log(`打开链接 ${colors.green(`http://127.0.0.1:${port}/md/`)} 即刻使用吧~`)
|
||||||
} catch (error) {
|
} else if(Date.now() - oldTime > 10 * 1e3) {
|
||||||
console.error(`启动错误 ${error}`)
|
clearInterval(timer)
|
||||||
|
console.log(`服务 ${port} 初始化失败, 请重试.`)
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
console.log(``)
|
}, 1e3);
|
||||||
}, 3*1e3);
|
|
||||||
}).catch(err => console.log(err))
|
}).catch(err => console.log(err))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@doocs/md-cli",
|
"name": "@doocs/md-cli",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"description": "✍ 一款高度简洁的微信 Markdown 编辑器:支持 Markdown 所有基础语法、色盘取色、一键复制并粘贴到公众号后台、多图上传、一键下载文档、自定义 CSS 样式、一键重置等特性",
|
"description": "✍ 一款高度简洁的微信 Markdown 编辑器:支持 Markdown 所有基础语法、色盘取色、一键复制并粘贴到公众号后台、多图上传、一键下载文档、自定义 CSS 样式、一键重置等特性",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user