1.0.40 • Published 4 months ago
app-lib-exec v1.0.40
一、背景介绍
- 直接通过js调动系统的脚本bat,shell等
进程自动化处理一些事情
二、功能描述
- 支持能在终端执行的所有命令
- 支持bat、shell等文件的直接执行
三、注意事项
- 打印乱码的时候 需要设置调用参数添加options.stdio即可
[{stdio: 'pipe'}]
option 支持的参数
* stidio 支持的 [pipe,overlapped,ignore,inherit] 分别对应 subprocess.stdin, subprocess.stdout, and subprocess.stderr的输出 'pipe': equivalent to ['pipe', 'pipe', 'pipe'] (the default) 'overlapped': equivalent to ['overlapped', 'overlapped', 'overlapped'] 'ignore': equivalent to ['ignore', 'ignore', 'ignore'] 'inherit': equivalent to ['inherit', 'inherit', 'inherit'] or [0, 1, 2] // Child will use parent's stdios. 自定义 stdio: ['pipe', 'pipe', process.stderr] // Spawn child sharing only stderr. * cwd 指定路径
四、使用案列
- 引用
const { exec } = require('app-lib-exec');
- 同步
exec('npm', ['list', '-g', '-depth', '0']);
- 执行文件
``` exec('tree.bat'); ```
五、todo列表
- 日志外层输出
六、API
exec(commondOrFile, args, options, isAsync) ⇒ null
数据类型判断
Kind: global function
Returns: null - 无返回
Examples
option下支持的参数
- stidio 支持的 pipe,overlapped,ignore,inherit
inherit // Child will use parent's stdios. stdio: ['pipe', 'pipe', process.stderr] // Spawn child sharing only stderr.
Param | Type | Default | Description |
---|---|---|---|
commondOrFile | string | 可执行的文件路径或者文件 | |
args | array | 所有命令行参数 | |
options | object | 执行参数配置 | |
isAsync | boolean | true | 是否同步 |
七、发布日志
- 2023-08-22 12-24-15-添加path-key错误情况
- 2023-08-21 11-35-58-发布为node版本
- 2023-08-20 08-03-26-添加注释
- 2023-08-20 08-01-32-添加注释
- 2023-08-20 08-01-05-添加注释
- 2023-04-20 11-01-24-移除依赖
- 2023-04-20 10-38-27-appbir
- 2023-04-20 10-05-40-修改package文件
- 2023-04-19 12-41-34-调整三方内部化
- 2023-04-19 12-38-40-调整日志
- 2023-04-19 10-52-02-添加注释
- 2023-04-19 10-51-16-添加注释
- 2022-11-11 10-28-22-undefined
- 2022-11-11 10-18-19-日志升级
- 2022-11-11 10-06-59-添加注释
1.0.40
4 months ago