# mp-cl

> 微信小程序开发工具

Latest version **1.0.2** (published 2021-10-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install mp-cl
pnpm add mp-cl
yarn add mp-cl
bun add mp-cl
```

Provides the command `mp-cli`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-10-19 |
| First published | 2021-10-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 40.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | osseini |
| Maintainers | osseini |

## Links

- npm: https://www.npmjs.com/package/mp-cl
- Repository: https://github.com/HosseiniShen/mp-cli
- Issues: https://github.com/HosseiniShen/mp-cli/issues
- npm.io page: https://npm.io/package/mp-cl

## Dependencies (6)

- [ora](https://npm.io/package/ora.md) ^5.4.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [slash](https://npm.io/package/slash.md) 3.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.1.1
- [commander](https://npm.io/package/commander.md) ^7.2.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) 6.0.0

## Recent versions

- 1.0.2 (latest) — 2021-10-19
- 1.0.1 — 2021-10-19
- 1.0.0 — 2021-10-19

## README

# 命令启动/关闭微信开发者工具

## 安装

```bash
npm install -D mp-cl
```

## 使用

打开指定项目路径（不指定项目会默认打开`/dist/build/mp-weixin`）

```bash
mp-cli open [projectPath]
```

关闭工具

```bash
mp-cli close [projectPath]
```

### 参数

- -D：测试环境（打开 `/dist/dev/mp-weixin`）
- -Q：关闭开发者工具（不加只会关闭项目）

### 最佳实践

```javascript
const { execFile } = require('child_process')
const fs = require('fs')
const path = require('path')
const os = require('os')

let hasSetup = false
module.exports = {
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'development') {
      config.plugins.push({
        apply: (compiler) => {
          compiler.hooks.done.tap('setupDevtool', compilation => {
            if (!hasSetup) {
              const ext = os.platform() === 'darwin' ? '' : '.cmd'
              const mpCli = path.resolve(process.cwd(), `./node_modules/.bin/mp-cli${ ext }`)
              if (fs.existsSync(mpCli)) {
                const child = execFile(mpCli, [ 'open', '-D' ], (error, stdout, stderr) => {
                  if (error) {
                    console.log(error)
                  }
                  hasSetup = true
                })
                child.stdout.pipe(process.stdout)
                process.stdin.pipe(child.stdin)
              }
            }
          });
        }
      })
    }
  }
}
```

---
_Source: https://npm.io/package/mp-cl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
