Skip to content

Commit ddb2a2e

Browse files
Add download url template for node.js
1 parent 2a53535 commit ddb2a2e

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,32 @@ Example composer.json
4141
}
4242
}
4343
```
44+
45+
## Configuration
46+
47+
There are three parameters you can configure: The node version (`node-version`), the yarn version (`yarn-version`) and
48+
the download url template for the node.js binary archives (`node-download-url`).
49+
50+
In the node download url the following parameters are replaced:
51+
52+
- version: `${version}`
53+
- type of your os: `${osType}`
54+
- system architecture: `${architecture}`
55+
- file format `${format}`
56+
57+
Example composer.json:
58+
59+
```json
60+
{
61+
// ...
62+
"extra": {
63+
"mariusbuescher": {
64+
"node-composer": {
65+
"node-version": "6.11.0",
66+
"yarn-version": "0.24.5",
67+
"node-download-url": "https://nodejs.org/dist/v${version}/node-v${version}-${osType}-${architecture}.${format}"
68+
}
69+
}
70+
}
71+
}
72+
```

src/Config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class Config
1616
*/
1717
private $yarnVersion;
1818

19+
/**
20+
* @var string
21+
*/
22+
private $nodeDownloadUrl;
23+
1924
/**
2025
* Config constructor.
2126
*/
@@ -32,6 +37,7 @@ public static function fromArray(array $conf)
3237
$self = new self();
3338

3439
$self->nodeVersion = $conf['node-version'];
40+
$self->nodeDownloadUrl = isset($conf['node-download-url']) ? $conf['node-download-url'] : null;
3541
$self->yarnVersion = isset($conf['yarn-version']) ? $conf['yarn-version'] : null;
3642

3743
if ($self->nodeVersion === null) {
@@ -57,4 +63,12 @@ public function getYarnVersion()
5763
{
5864
return $this->yarnVersion;
5965
}
66+
67+
/**
68+
* @return string
69+
*/
70+
public function getNodeDownloadUrl()
71+
{
72+
return $this->nodeDownloadUrl;
73+
}
6074
}

src/NodeComposerPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function onPostUpdate(Event $event)
6767
$nodeInstaller = new NodeInstaller(
6868
$this->io,
6969
new RemoteFilesystem($this->io, $this->composer->getConfig()),
70-
$context
70+
$context,
71+
$this->config->getNodeDownloadUrl()
7172
);
7273

7374
$installedNodeVersion = $nodeInstaller->isInstalled();

0 commit comments

Comments
 (0)