Skip to content

Commit 0b74865

Browse files
committed
Allow ignoring of Composer scripts after update/install/etc.
To keep parity with Composer, we will allow scripts by default, but the README does indicate that these should be disabled if this library is used in a web context.
1 parent d290889 commit 0b74865

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Commands/Update.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ class Update extends BaseCommand
3838
protected $ignorePlatformReqs = false;
3939

4040
/**
41-
* @var boolean Prefer dist releases of packages
41+
* @var string Prefer dist releases of packages
4242
*/
43-
protected $installPreference = [''];
43+
protected $installPreference = 'none';
44+
45+
/**
46+
* @var boolean Ignore scripts that run after Composer events.
47+
*/
48+
protected $ignoreScripts = false;
4449

4550
/**
4651
* @var boolean Whether this command has already been executed
@@ -87,13 +92,15 @@ class Update extends BaseCommand
8792
* @param boolean $lockFileOnly Do a lockfile update only, do not install dependencies.
8893
* @param boolean $ignorePlatformReqs Ignore platform reqs when running the update.
8994
* @param string $installPreference Set an install preference - must be one of "none", "dist", "source"
95+
* @param boolean $ignoreScripts Ignores scripts that run after Composer events.
9096
* @return void
9197
*/
9298
public function handle(
9399
bool $includeDev = true,
94100
bool $lockFileOnly = false,
95101
bool $ignorePlatformReqs = false,
96-
string $installPreference = 'none'
102+
string $installPreference = 'none',
103+
bool $ignoreScripts = false
97104
) {
98105
if ($this->executed) {
99106
return;
@@ -102,6 +109,7 @@ public function handle(
102109
$this->includeDev = $includeDev;
103110
$this->lockFileOnly = $lockFileOnly;
104111
$this->ignorePlatformReqs = $ignorePlatformReqs;
112+
$this->ignoreScripts = $ignoreScripts;
105113

106114
if (in_array($installPreference, [self::PREFER_NONE, self::PREFER_DIST, self::PREFER_SOURCE])) {
107115
$this->installPreference = $installPreference;
@@ -339,6 +347,10 @@ public function arguments(): array
339347
$arguments['--ignore-platform-reqs'] = true;
340348
}
341349

350+
if ($this->ignoreScripts) {
351+
$arguments['--no-scripts'] = true;
352+
}
353+
342354
if (in_array($this->installPreference, [self::PREFER_DIST, self::PREFER_SOURCE])) {
343355
$arguments['--prefer-' . $this->installPreference] = true;
344356
}

0 commit comments

Comments
 (0)