PHP 编辑器脚本不触发



我正在尝试让安装后和更新后的脚本在Composer包中工作。以下是composer.json文件的摘录:

"autoload": {
    "psr-4": {
        "App\": "src/"
    }
},
"scripts": {
    "post-update-cmd": [
        "App\Install\ComposerScripts::postUpdate"
    ],
    "post-install-cmd": [
        "App\Install\ComposerScripts::postInstall",
        "./test.sh"
    ]
}

这里是ComposerScripts.php:

<?php
namespace AppInstall;
use ComposerScriptEvent;
class ComposerScripts
{
    public static function postInstall(Event $event)
    {
        $io = $event->getIO();
        if ($io->askConfirmation('Install Mecab? ', false)) {
            return true;
        }
        exit;
    }
    public static function postUpdate(Event $event)
    {
        $event->getIO()->write("Working!");
        return true;
    }
}

和文件test.sh:

#!/bin/sh
echo Working

如果我用composer run-script测试ComposerScripts方法,并且test.sh脚本运行良好,那么ComposerScript方法就可以工作,但当我安装或更新包时,什么都不会发生。没有输出,没有错误,什么都没有。知道这里发生了什么吗?

尝试

"autoload": {
    "psr-4": {
        "App\": "src/"
    }
},
"scripts": {
    "post-update-cmd": [
        "App\Install\ComposerScripts::postUpdate"
    ],
    "post-install-cmd": [
        "App\Install\ComposerScripts::postInstall",
        "bash test.sh"
    ]
}

相关内容

  • 没有找到相关文章

最新更新