Skip to content

Commit 1ad9c66

Browse files
authored
Merge pull request #632 from bincrafters/nodejs
Add Nodejs
2 parents 8d59878 + adc6104 commit 1ad9c66

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

recipes/nodejs/all/conandata.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sources:
2+
"12.14.1":
3+
- url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-win-x64.zip"
4+
sha256: "1f96ccce3ba045ecea3f458e189500adb90b8bc1a34de5d82fc10a5bf66ce7e3"
5+
- url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz"
6+
sha256: "07cfcaa0aa9d0fcb6e99725408d9e0b07be03b844701588e3ab5dbc395b98e1b"
7+
- url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-darwin-x64.tar.gz"
8+
sha256: "0be10a28737527a1e5e3784d3ad844d742fe8b0718acd701fd48f718fd3af78f"
9+
"13.6.0":
10+
- url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-win-x64.zip"
11+
sha256: "7fe37b34a4673a071bea52fcaf913ec422cf6fd79fd025bfb22de42ccc77f386"
12+
- url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-linux-x64.tar.xz"
13+
sha256: "00f01315a867da16d1638f7a02966c608e344ac6c5b7d04d1fdae3138fa9d798"
14+
- url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-darwin-x64.tar.gz"
15+
sha256: "da13adb864777b322dda7af20410a9b0c63aa69de4b5574008d1e6910768bf69"

recipes/nodejs/all/conanfile.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
from conans import ConanFile, tools
3+
from conans.errors import ConanInvalidConfiguration
4+
5+
6+
class NodejsInstallerConan(ConanFile):
7+
name = "nodejs"
8+
description = "nodejs binaries for use in recipes"
9+
topics = ("conan", "node", "nodejs")
10+
url = "https://github.com/conan-io/conan-center-index"
11+
homepage = "https://nodejs.org"
12+
license = "MIT"
13+
settings = {"os_build": ["Windows", "Linux", "Macos"], "arch_build": ["x86_64"]}
14+
no_copy_source = True
15+
16+
@property
17+
def _source_subfolder(self):
18+
return os.path.join(self.source_folder, "source_subfolder")
19+
20+
def source(self):
21+
os_name = {"Windows": "-win", "Macos": "-darwin", "Linux": "-linux"}
22+
for data in self.conan_data["sources"][self.version]:
23+
sha, url = data.values()
24+
filename = url[url.rfind("/")+1:]
25+
tools.download(url, filename)
26+
tools.check_sha256(filename, sha)
27+
if os_name[str(self.settings.os_build)] in url:
28+
tools.unzip(filename)
29+
os.rename(filename[:filename.rfind("x64")+3], self._source_subfolder)
30+
31+
def package(self):
32+
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
33+
self.copy(pattern="*", src=os.path.join(self._source_subfolder, "bin"), dst="bin")
34+
self.copy(pattern="node.exe", src=self._source_subfolder, dst="bin")
35+
self.copy(pattern="npm", src=self._source_subfolder, dst="bin")
36+
self.copy(pattern="npx", src=self._source_subfolder, dst="bin")
37+
38+
def package_info(self):
39+
bin_dir = os.path.join(self.package_folder, "bin")
40+
self.output.info('Appending PATH environment variable: {}'.format(bin_dir))
41+
self.env_info.PATH.append(bin_dir)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
from conans import ConanFile, tools
3+
4+
5+
class TestPackageConan(ConanFile):
6+
7+
def test(self):
8+
self.output.info("Node version:")
9+
self.run("node --version", run_environment=True)

recipes/nodejs/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
versions:
2+
"12.14.1":
3+
folder: all
4+
"13.6.0":
5+
folder: all

0 commit comments

Comments
 (0)