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 🙏

© 2024 – Pkg Stats / Ryan Hefner

freedom-util-shell

v1.0.10

Published

简单的多平台环境的shell命令执行工具

Downloads

27

Readme

freedom-util-shell

简单的shell命令执行工具,可支持在mac、linux、windows平台下使用

npm NPM Version npm

如何使用

  • 安装

    cnpm/npm install freedom-util-shell --save
  • 使用demo

    const shell = require("freedom-util-shell")();
    
    (async function () {
      let result = await shell.execCmd("git log", false);
      let regExp = /commit\s*(((?!Author).)+)Author/gm;
      if (regExp.test(result)) {
        console.log("============" + RegExp.$1 + "============");
      }
    })();

API

  • 构造器

    构造器提供了一个option对象,提供以下参数
     shellCmd:指定shell命令的执行程序,比如:linux系统下的sh程序,windows系统下的cmd.exe程序
  • execCmd

    shell命令执行方法,该方法提供2个参数
     shellCmds:string|Array<string>类型 单个的shell命令,或者多个shell命令
     isOutput:boolean类型,是否输出shell执行结果,true为输出,false为不输出,默认值为true,可选
     opts:object类型,可选参数,该参数提供以下值,可选
    	cwd:string 类型,shell执行的目录,请参考node中child_process的spawn提供的可选参数
     flags:Array<string> 类型,指定的系统操作符,可选
      	

版本更新说明

  • 1.0.2
    1. fixed在执行完指定目录下的命令的时候,会删除此命令的bug
  • 1.0.3
    1. fixed执行命令编码的问题,指定为utf-8
    2. 指定命令执行路径
    3. windows下,指定shell进程,隐式调用cmd.exe
  • 1.0.5
    1. fixed在指定命令执行目录的bug
  • 1.0.6
    1. fixed连续执行命令出现的bug
  • 1.0.7
    1. fixed在window下执行带有 ^ 这种符号的bug
  • 1.0.8
    1. fixed执行多个命令,即shellCmds为Array类型时,mac系统下无法执行的bug
  • 1.0.10
    1. fixed在windows下面执行指定绝对路径【/d/dev-tool/cli.bat】的命令失败的bug

备注

建议node > 8.x.x版本

请参考test目录测试该项目