簡體   English   中英

PHP Composer腳本不會觸發

[英]PHP Composer scripts don't fire

我正在嘗試在Composer包中使用post安裝和發布更新腳本。 以下是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 App\Install;

use Composer\Script\Event;

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測試它們並且test.sh腳本工作正常,則ComposerScripts方法有效,但是當我安裝或更新包時,根本沒有任何事情發生。 沒有輸出,沒有錯誤,沒有。 知道這里發生了什么嗎?

嘗試

"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM