1.2.5 • Published 3 years ago

pomelo-toolbox v1.2.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

pomelo-toolbox

daily node utils.

features

  • prettier command line
  • json tools
  • ssh tools
  • logger & loading
    const {cmd} = require('pomelo-toolbox');

API

cmd.exec

  • 参数
paramtypedescription
cmdString命令
optObjectexec options for child_process
  • 返回值 Promise
await cmd.exec(cmd, opt)

cmd.classify

  • 参数
paramtypedescription
argvprocess.argvnode 命令行 process.argv
  • 返回值 Object

        Object {
            all: argv,  // 所有参数的key value形式
            valuableParam,  // 有效参数
            cmdParam,  // 子命令
            objParam,  // 带等于号的参数
            commonParam,
            nameParam
        }
    ```
cmd.classify(process.argv)

Json

const {json} = require('pomelo-toolbox');

json.upJson

  • 参数
paramtypedescription
cbFunction注入json文件内容的钩子,需要在函数中增加返回值。
pathStringjson文件的路径
  • 返回值 Promise

        json.upJson((jsonData) => {
            jsonData.name = 'test';
            return jsonData;
        }, './test.json')

json.readJson

  • 参数
paramtypedescription
pathFunctionjson文件的路径
keyString需要读取的key
  • 返回值 String
    json.readJson('./package.json')
    json.readJson('./package.json', 'version')

json.appendJson(path, dataObj)

  • 参数 | param | type | description | |:---:|:---:|:---:| | path | String| json文件的路径 | | dataObj | Object |需要为文件追加的数据|

  • 返回值 Boolean

    json.appendJson('./package.json', {
        test: 'test str'
    })

json.writeJson

说明同appendJson相同, 但writeJson为全量覆盖

Print

    const {print} = require('pomelo-toolbox')

print.Plog

  • 参数
paramtypedescription
optObjectPlog的配置项
  • 返回值 Plog实例
    const Plog = require('pomelo-toolbox').Plog;
    new Plog({
        prefix: "pomelo-toolbox",
        des: true
    })

print.LogLoading

  • 参数
paramtypedescription
optObjectLogLoading的配置项
  • 返回值 LogLoading实例
    const {LogLoading} = require('pomelo-toolbox').LogLoading;
    new LogLoading({
        txt: "we are trying, please wait...",
        prefixText: "",
        color: "cyan"
    })

print.LogPromise

  • 参数 | param | type | description | |:---:|:---:|:---:| |pro|Promise|| |opt|Object|LogLoading的配置项 |

  • 返回值 LogLoading实例

    const LogPromise = require('pomelo-toolbox').LogPromise;
    new LogPromise(pro, 'initing ...');
    new LogPromise(pro, opt);

SSH

    const {ssh} =  require('pomelo-toolbox');

ssh.ssh

  • 参数
paramtypedescription
optObjectLogLoading的配置项
  • 返回值 Promise
    ssh.ssh({
        host: '192.168.1.111',
        port: '8888',
        username: 'root',
        password: '123'
    })

Step

    const {step} = require('pomelo-toolbox');

step.next

  • 参数
paramtypedescription
cbFunction异步回调
  • 返回值 Promise
    step.next((resolve) => {
        if (..) {
            resolve(true)
        }
    })

step.sleep

  • 参数 | param | type | description | |:---:|:---:|:---:| |time|Number|延时时间| |cb|Function|延时结束时间|

  • 返回值 Promise

    await step.sleep(3000)
1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.26

4 years ago

1.0.27

4 years ago

1.0.22

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago