Skip to content

Commit

Permalink
Adding support for ARM processors for NodeJS > 4.0. See #17
Browse files Browse the repository at this point in the history
  • Loading branch information
moufmouf committed Sep 16, 2015
1 parent 397968c commit dbc3b29
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public static function isArm()
return strpos(strtolower(php_uname("m")), "arm") === 0;
}

/**
* @return bool True if processor is Armv7l.
*/
public static function isArmV7l()
{
return php_uname("m") === 'armv7l';
}

/**
* @return bool True if processor is Armv6l.
*/
public static function isArmV6l()
{
return php_uname("m") === 'armv6l';
}

/**
* @return int Returns 32 or 64 depending on supported architecture.
*/
Expand Down
14 changes: 13 additions & 1 deletion src/NodeJsInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,19 @@ public function getNodeJSUrl($version)
} elseif (Environment::isSunOS() && Environment::getArchitecture() == 64) {
return "https://nodejs.org/dist/v".$version."/node-v".$version."-sunos-x64.tar.gz";
} elseif (Environment::isLinux() && Environment::isArm()) {
throw new NodeJsInstallerException('NodeJS-installer cannot install Node on computers with ARM processors. Please install NodeJS globally on your machine first, then run composer again.');
if (version_compare($version, '4.0.0') >= 0) {
if (Environment::isArmV6l()) {
return "https://nodejs.org/dist/v".$version."/node-v".$version."-armv6l.tar.gz";
} elseif (Environment::isArmV7l()) {
return "https://nodejs.org/dist/v".$version."/node-v".$version."-armv7l.tar.gz";
} elseif (Environment::getArchitecture() == 64) {
return "https://nodejs.org/dist/v".$version."/node-v".$version."-arm64.tar.gz";
} else {
throw new NodeJsInstallerException('NodeJS-installer cannot install Node on computers with ARM 32bits processors that are not v6l or v7l. Please install NodeJS globally on your machine first, then run composer again.');
}
} else {
throw new NodeJsInstallerException('NodeJS-installer cannot install Node <4.0 on computers with ARM processors. Please install NodeJS globally on your machine first, then run composer again, or consider installing a version of NodeJS >=4.0.');
}
} elseif (Environment::isLinux() && Environment::getArchitecture() == 32) {
return "https://nodejs.org/dist/v".$version."/node-v".$version."-linux-x86.tar.gz";
} elseif (Environment::isLinux() && Environment::getArchitecture() == 64) {
Expand Down

0 comments on commit dbc3b29

Please sign in to comment.