{"id":21669523,"url":"https://github.com/51talk-design/freedom-util-shell","last_synced_at":"2026-04-05T08:31:28.324Z","repository":{"id":57241589,"uuid":"152571033","full_name":"51talk-design/freedom-util-shell","owner":"51talk-design","description":"简单的多平台环境的shell命令执行工具","archived":false,"fork":false,"pushed_at":"2018-12-07T03:49:18.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T18:19:50.636Z","etag":null,"topics":["freedom","javascript","shell","util"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/51talk-design.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-11T10:06:38.000Z","updated_at":"2021-09-09T06:28:20.000Z","dependencies_parsed_at":"2022-09-08T00:40:47.489Z","dependency_job_id":null,"html_url":"https://github.com/51talk-design/freedom-util-shell","commit_stats":null,"previous_names":["ljcheibao/freedom-util-shell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/51talk-design%2Ffreedom-util-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/51talk-design%2Ffreedom-util-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/51talk-design%2Ffreedom-util-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/51talk-design%2Ffreedom-util-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/51talk-design","download_url":"https://codeload.github.com/51talk-design/freedom-util-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244570954,"owners_count":20474153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["freedom","javascript","shell","util"],"created_at":"2024-11-25T12:23:12.740Z","updated_at":"2025-12-30T20:56:21.361Z","avatar_url":"https://github.com/51talk-design.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### freedom-util-shell\n\n简单的shell命令执行工具，可支持在mac、linux、windows平台下使用\n\n[![npm](https://img.shields.io/npm/l/freedom-util-shell.svg)](LICENSE)\n[![NPM Version](https://img.shields.io/npm/v/freedom-util-shell.svg)](https://www.npmjs.com/package/freedom-util-shell)\n[![npm](https://img.shields.io/npm/dt/freedom-util-shell.svg)](https://www.npmjs.com/package/freedom-util-shell)\n\n### 如何使用\n\n- 安装\n\n  ```\n  cnpm/npm install freedom-util-shell --save\n  ```\n\n- 使用demo\n\n  ```js\n  const shell = require(\"freedom-util-shell\")();\n\n  (async function () {\n    let result = await shell.execCmd(\"git log\", false);\n    let regExp = /commit\\s*(((?!Author).)+)Author/gm;\n    if (regExp.test(result)) {\n      console.log(\"============\" + RegExp.$1 + \"============\");\n    }\n  })();\n  ```\n\n### API\n\n- 构造器\n\n  ```\n  构造器提供了一个option对象，提供以下参数\n   shellCmd：指定shell命令的执行程序，比如：linux系统下的sh程序，windows系统下的cmd.exe程序\n  ```\n\n- execCmd\n\n  ```\n  shell命令执行方法，该方法提供2个参数\n   shellCmds:string|Array\u003cstring\u003e类型 单个的shell命令，或者多个shell命令\n   isOutput：boolean类型，是否输出shell执行结果，true为输出，false为不输出，默认值为true，可选\n   opts：object类型，可选参数，该参数提供以下值，可选\n  \tcwd:string 类型，shell执行的目录，请参考node中child_process的spawn提供的可选参数\n   flags:Array\u003cstring\u003e 类型，指定的系统操作符，可选\n  \t\n  ```\n\n### 版本更新说明\n\n- 1.0.2\n  1. fixed在执行完指定目录下的命令的时候，会删除此命令的bug\n- 1.0.3\n  1. fixed执行命令编码的问题，指定为utf-8\n  2. 指定命令执行路径\n  3. windows下，指定shell进程，隐式调用cmd.exe\n- 1.0.5\n  1. fixed在指定命令执行目录的bug\n- 1.0.6\n  1. fixed连续执行命令出现的bug\n- 1.0.7\n  1. fixed在window下执行带有 ^ 这种符号的bug\n- 1.0.8\n  1. fixed执行多个命令，即shellCmds为Array\u003cstring\u003e类型时，mac系统下无法执行的bug\n- 1.0.10\n  1. fixed在windows下面执行指定绝对路径【**/d/dev-tool/cli.bat**】的命令失败的bug\n\n### 备注\n\n**建议node \u003e 8.x.x版本**\n\n### 请参考test目录测试该项目\n\n  ​\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F51talk-design%2Ffreedom-util-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F51talk-design%2Ffreedom-util-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F51talk-design%2Ffreedom-util-shell/lists"}