Skip to content

Commit f319afb

Browse files
Add check after installation
1 parent bf01007 commit f319afb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/NodeComposerPlugin.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ public function onPostUpdate(Event $event)
8585
$nodeInstaller->install($this->config->getNodeVersion());
8686

8787
$this->io->write('');
88+
89+
$installedNodeVersion = $nodeInstaller->isInstalled();
90+
if (strpos($installedNodeVersion, 'v' . $this->config->getNodeVersion()) === false) {
91+
throw new \RuntimeException('Could not verify node.js installation');
92+
} else {
93+
$this->io->write(sprintf(
94+
'node.js v%s installed',
95+
$this->config->getNodeVersion()
96+
));
97+
}
8898
}
8999

90100
if ($this->config->getYarnVersion() !== null) {
@@ -105,6 +115,16 @@ public function onPostUpdate(Event $event)
105115
));
106116

107117
$yarnInstaller->install($this->config->getYarnVersion());
118+
119+
$installedYarnVersion = $yarnInstaller->isInstalled();
120+
if (strpos($installedYarnVersion, $this->config->getYarnVersion()) === false) {
121+
throw new \RuntimeException('Could not verify yarn version');
122+
} else {
123+
$this->io->write(sprintf(
124+
'node.js v%s installed',
125+
$this->config->getNodeVersion()
126+
));
127+
}
108128
}
109129
}
110130
}

0 commit comments

Comments
 (0)