These are chat archives for composer/composer

28th
Jun 2016
Jürgen Haas
@jurgenhaas
Jun 28 2016 08:08

I do have a package which defines scripts in their composer.json but those don't get executed when I install or update the main app. The declaration looks like this:

  "scripts": {
    "post-package-install": "npm install",
    "post-package-update": "npm update"
  },

What's wrong with this? Are those commands executed in the package directory or in the root directory?

Ben Johnson
@mmic-bjohnson
Jun 28 2016 13:27
@jurgenhaas You sure you have the correct property names there?
Mine look like
"scripts": {
    "post-install-cmd": [
        ...
    ],
    "pre-update-cmd": [
        ...
    ],
    "post-update-cmd": [
        ...
    ]
},
Jürgen Haas
@jurgenhaas
Jun 28 2016 13:28
@mmic-bjohnson well I had post-install-cmd and post-update-cmd before but they didn't work either. So I went to the composer documentation and found those other two, that sounded reasonable.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 13:30
@jurgenhaas Are you running Composer with -vvv? How do you know that the scripts aren't being run?
Jürgen Haas
@jurgenhaas
Jun 28 2016 13:31
I haven't tried -vvv yet, I just thought so because if they were running they would have created node_modules subdirectories which they haven't.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 13:32
@jurgenhaas Gotcha, that's reasonable
Give it a try on super-verbose and see if it tells you anything you didn't already know
Jürgen Haas
@jurgenhaas
Jun 28 2016 13:33
@mmic-bjohnson good point, I'll give it a try
Jürgen Haas
@jurgenhaas
Jun 28 2016 14:18
@mmic-bjohnson no luck, with neither of the properties above. It doesn't mention any of the script events from the package but only executes the script from the main composer.json.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 14:20
Ooooh, this is in a package's composer.json? I missed that part.
You did say that. :)
I've never tried to do that...
Jürgen Haas
@jurgenhaas
Jun 28 2016 14:32
Any idea where I could find out?
Ben Johnson
@mmic-bjohnson
Jun 28 2016 14:40

@jurgenhaas Right at the top of the relevant manual page ( https://getcomposer.org/doc/articles/scripts.md ):

Note: Only scripts defined in the root package's composer.json are executed. If a dependency of the root package specifies its own scripts, Composer does not execute those additional scripts.

There you have it.
Jürgen Haas
@jurgenhaas
Jun 28 2016 14:41
Yeah, just also found a thread in composer/composer#1193 where they discussed this issue with regard to security implications.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 14:43
Simply not possible and won't be implemented, I suppose? :/
Jürgen Haas
@jurgenhaas
Jun 28 2016 14:50
That's my understanding too. However, the eloquent/composer-npm-bridge looks promissing - just trying that.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 14:53
@jurgenhaas Cool, please do let us know if it works for your use-case.
Jürgen Haas
@jurgenhaas
Jun 28 2016 14:53
Will certainly do. Thanks @mmic-bjohnson for your help.
Ben Johnson
@mmic-bjohnson
Jun 28 2016 14:57
@jurgenhaas :thumbsup: Any time, and thank you!