recipe-runner/system-module

系统模块,包含执行命令和处理文件的方法

dev-master / 1.0.x-dev 2019-08-14 14:49 UTC

This package is auto-updated.

Last update: 2024-09-15 01:53:52 UTC


README

Build Status

需求

安装

创建一个配方并将模块添加到packages部分

name: "Your recipe"
extra:
  rr:
    packages:
      "recipe-runner/system-module": "1.0.x-dev"

用法

方法: run

执行命令。

steps:
    - actions:
        - run: "echo hi user"

命令可以分成命令和参数。这样,参数将自动转义。

steps:
    - actions:
        run:
            command:
                "echo"      # Command
                "hi user"   # parameter 1

您还可以设置超时和当前工作目录

steps:
    - actions:
        - run:
            command: "echo hi user"
            timeout: 60
            cwd: "/temp"

方法: copy_file

复制单个文件。

steps:
    - actions:
        - copy_file:
            from: "/dir1/file.txt"
            to: "/tmp/file.txt"

方法: download_file

从网络下载文件。

steps:
    - actions:
        - download_file: 
            url: "https://phar.phpunit.de/phpunit-8.phar"
            filename: "phpunit.phar"

方法: make_dir

递归创建目录。在POSIX文件系统中,目录以默认模式值0777创建。

steps:
    - actions:
        - make_dir: "/dir1"

或者您可以使用参数mode设置目录模式

steps:
    - actions:
        - make_dir:
            dir: "/dir1"
            mode: 0777

方法: mirror_dir

将源目录的所有内容复制到目标目录。

steps:
    - actions:
        - mirror_dir:
            from: "/dir1"
            to: "/tmp"

方法: read_file

读取文件或URL地址的内容。

steps:
    - actions:
        - read_file: "/tmp/hi.txt"
          register: "file_content"

文件内容在content中可用

registered["file_content"]["content"]

## or

registered.get('file_content.content')

方法: remove

删除文件、目录和符号链接。

steps:
    - actions:
        - remove: "/tmp/hi.txt"

或者

steps:
    - actions:
        - remove: 
            - "/tmp/hi.txt"
            - "/dir1"
            - "/home/user/symlink1.sh"

方法: write_file

将给定内容保存到文件中。

steps:
    - actions:
        - write_file:
            filename: "/tmp/hi.txt"
            content: "hi user"

对于模块开发者

首选的安装方法是Composer

composer require recipe-runner/system-module

单元测试

您可以使用以下命令运行单元测试

$ cd system-module
$ composer test

许可协议

本库是开源软件,许可协议为MIT许可协议