Skip to content

Commit 359d36c

Browse files
authored
Merge pull request #19 from Ultimaker/NP-733
NP-733
2 parents 87c71e3 + 2c81a01 commit 359d36c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

recipes/npmpackage/all/conanfile.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
from conan import ConanFile
2-
1+
import os
32
from pathlib import Path
43

4+
from conan import ConanFile
5+
56
required_conan_version = ">=2.7.0"
67

78

89
def sanitize_version(version):
9-
# npm will otherwise 'sanitize' the version number
10-
return version.replace("+", "-")
10+
# npm will otherwise 'sanitize' the version number
11+
return version.replace("+", "-")
1112

1213

13-
def conf_package_json(conanfile: ConanFile, **kwargs):
14-
entry_point = [p.name for p in Path(conanfile.package_folder, "bin").rglob("*.js")][0]
14+
def generate_package_json(conanfile: ConanFile, entry_point, **kwargs):
1515
package_json = {
1616
"name": f"@{conanfile.author.lower()}/{conanfile.name.lower()}js",
1717
"version": f"{sanitize_version(conanfile.version)}",
1818
"description": f"JavaScript / TypeScript bindings for {conanfile.name}, a {conanfile.description}",
19-
"main": f"bin/{entry_point}",
19+
"main": entry_point,
2020
"repository": {
2121
"type": "git",
2222
"url": conanfile.url
@@ -25,13 +25,18 @@ def conf_package_json(conanfile: ConanFile, **kwargs):
2525
"license": conanfile.license,
2626
"keywords": conanfile.topics,
2727
"files": [
28-
"bin",
28+
str(Path(entry_point).parent),
2929
"package.json"
3030
]
3131
}
3232
package_json |= kwargs
33-
conanfile.output.info(f"Generated package.json: {package_json}")
33+
return package_json
34+
3435

36+
def conf_package_json(conanfile: ConanFile, **kwargs):
37+
package_json = generate_package_json(conanfile,
38+
os.path.join(conanfile.cpp.package.bindirs[0], conanfile.cpp.package.bin[0]),
39+
**kwargs)
3540
conanfile.conf_info.define(f"user.{conanfile.name.lower()}:package_json", package_json)
3641

3742

recipes/npmpackage/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
versions:
2-
"1.0.0":
2+
"1.1.0":
33
folder: "all"

0 commit comments

Comments
 (0)