gmdotnet / composer-copy-file

Composer 脚本在安装或更新后复制您的目录和文件

0.3.0 2017-08-29 07:20 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:38 UTC


README

Composer 脚本在安装后复制您的文件。支持复制整个目录、单个文件和复杂的嵌套目录。

例如复制字体

{
    "require":{
        "twbs/bootstrap": "~3.3",
        "gmdotnet/composer-copy-file": "~0.3"
    },
    "scripts": {
        "post-install-cmd": [
            "GMdotnet\\CopyFile\\ScriptHandler::copy"
        ],
        "post-update-cmd": [
            "GMdotnet\\CopyFile\\ScriptHandler::copy"
        ]
    },
    "extra": {
        "copy-file": {
            "vendor/twbs/bootstrap/fonts/": "web/fonts/"
        }
    }
}

用例

在使用最后一个斜杠时需要小心。文件目标与目录目标在斜杠处不同。

源目录层次结构

dir/
    subdir/
        file1.txt
        file2.txt
        .filehidden
  1. 目录到目录

    {
        "extra": {
            "copy-file": {
                "dir/subdir/": "web/other/"
            }
        }
    }
    

    结果

    web/
        other/
            file1.txt
            file2.txt
            .filehidden
    
  2. 文件到目录

    {
        "extra": {
            "copy-file": {
                "dir/subdir/file1.txt": "web/other/"
                "dir/subdir/file2.txt": "web/other/file2.txt/"
            }
        }
    }
    

    结果

    web/
        other/
            file1.txt
            file2.txt/
                file2.txt
    
  3. 文件到文件

    {
        "extra": {
            "copy-file": {
                "dir/subdir/file1.txt": "web/other/file1.txt"
                "dir/subdir/file2.txt": "web/other/file_rename.txt"
            }
        }
    }
    

    结果

    web/
        other/
            file1.txt
            file_rename.txt
    

致谢

感谢 Slowprog 提供基础项目 - https://github.com/slowprog
Giuseppe Morelli - giuseppemorelli.net