npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@xueliang/cmdrun

v0.4.6

Published

cmdrun help you run your command on other system

Readme

Cmdrun

NPM version

cmdrun 一个可以自定义命令的解决方案,方便开发者快速集成自己的工具命令;使自己的非 node 工具可以在各个平台使用命令;

例如docker命令的集成,利用熟悉的 js 代码去拼成 要执行代码,集成起来,只需要简单cmdrun dockerStart 即可启动复杂的docker命令

// 举例
// 命令

module.exports = {
  'actDev-des': '启动开发服务',
  actDev: function (port) {
    let path = require('path')
    var basePath = process.cwd()
    // let parentPath = path.dirname(basePath)
    let workdir = '/workdir/vue'
    let name = this._getActName(basePath)
    let images = this._getImages()
    let libpath = this.getLibPath(basePath)
    let publicPath = this._getPublic(basePath + '/src')
    port = port || 1900
    var docker = `docker run -i -v  ${basePath}:${workdir}/myapp -v ${libpath}:${workdir}/lib  ${
      publicPath ? `-v ${publicPath}:${workdir}/public` : ''
    }  --rm  -p ${port}:${port}/tcp --name ${name}-d-${port} -e PORT=${port} ${images}  yarn start  `
    console.log(docker)
    this.run(docker, function () {
      console.log('执行成功')
      console.log(docker)
    })
  },
}
// 调用
# cmdrun 调用 actDev 命令 传递端口 会执行一串复杂的docker命令
cmdrun actDev 1234

该工具用法:

0.4.0 新增支持在项目中调用cmdrun 命令

需要在项目目录下安装 npm i @xueliang/cmdrun -S

const cmdrun = require('@xueliang/cmdrun')
cmdrun.run('help')

该工具已集成 Cli 命令

  • cmdrun init 初始化一个自定义命令 demo,文件为 cmdrun.config.js,在文件中按照例子添加自己的方法即可;

  • cmdrun add 添加 cmdrun.config.js 的方法到命令中;使用cmdrun进行调用

  • cmdrun del [name] 删除 name 方法,或删除对应的 cmdrun.config.js 内的方法

  • cmdrun clear清空方法

cmdrun.config.js 配置文件如下

module.exports = {
  "show-des":`方法描述`
  show: function(...param) {
    console.log(...param);
  }
};

在编写自定义命令时可以使用this.run('cmd',success=()=>{},error=()=>{})来调用系统的命令;

使用 cmdrun show

使用 Cli 方法

全局安装 cmdrun

npm i @xueliang/cmdrun -g

自定函数可能用到的方法

this.run() 执行系统命令

this.log()打印数据

this.log.red()红色输出文字


更新日志:

  • v-0.4.0

    • 命令缓存目录替换到用户目录下的 .cmdrun 目录

    • 支持在项目中安装并且引用调用已经设置好的命令; 需要在项目目录下安装 npm i @xueliang/cmdrun -S

      const cmdrun = require('@xueliang/cmdrun')
      cmdrun.run('help')
  • v-0.3.0

    • 添加支持自定义方法说明