npm, node-js, typescript: add external find (#48587)
* npm: add external find * node-js: add external find * Add external for typescript * Match full executable string * Fix style
This commit is contained in:
parent
08c53fa405
commit
9296527775
@ -2,6 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@ -137,6 +138,14 @@ class NodeJs(Package):
|
||||
# and https://github.com/nodejs/node/issues/53633
|
||||
patch("fix-broken-gcc12-pr53728.patch", when="@22.2:22.5")
|
||||
|
||||
executables = ["^node$"]
|
||||
|
||||
@classmethod
|
||||
def determine_version(cls, exe):
|
||||
output = Executable(exe)("--version", output=str, error=str)
|
||||
match = re.match(r"v([\d.]+)\s*", output)
|
||||
return match.group(1) if match else None
|
||||
|
||||
def setup_build_environment(self, env):
|
||||
# Force use of experimental Python 3 support
|
||||
env.set("PYTHON", self.spec["python"].command.path)
|
||||
|
@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from spack.package import *
|
||||
@ -15,6 +16,8 @@ class Npm(Package):
|
||||
url = "https://registry.npmjs.org/npm/-/npm-9.3.1.tgz"
|
||||
git = "https://github.com/npm/cli.git"
|
||||
|
||||
tags = ["build-tools"]
|
||||
|
||||
license("Artistic-2.0")
|
||||
|
||||
version("9.3.1", sha256="41caa26a340b0562bc5429d28792049c980fe3e872b42b82cad94e8f70e37f40")
|
||||
@ -45,6 +48,14 @@ class Npm(Package):
|
||||
when="@6",
|
||||
)
|
||||
|
||||
executables = ["^npm$"]
|
||||
|
||||
@classmethod
|
||||
def determine_version(cls, exe):
|
||||
output = Executable(exe)("--version", output=str, error=str).strip()
|
||||
match = re.match(r"([\d.]+)\s*", output)
|
||||
return match.group(1) if match else None
|
||||
|
||||
@when("@6")
|
||||
def patch(self):
|
||||
shutil.rmtree("node_modules/node-gyp")
|
||||
|
@ -3,6 +3,8 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
@ -12,6 +14,8 @@ class Typescript(Package):
|
||||
homepage = "https://www.typescriptlang.org"
|
||||
url = "https://github.com/microsoft/TypeScript/archive/refs/tags/v5.3.2.tar.gz"
|
||||
|
||||
tags = ["build-tools"]
|
||||
|
||||
license("Apache-2.0")
|
||||
|
||||
version("5.3.2", sha256="c5a12507006e7d2b8020dec9589191ce070fd88203f2c80aca00d641cee7866f")
|
||||
@ -19,6 +23,14 @@ class Typescript(Package):
|
||||
depends_on("node-js", type=("build", "link", "run"))
|
||||
depends_on("npm", type="build")
|
||||
|
||||
executables = ["^tsc$"]
|
||||
|
||||
@classmethod
|
||||
def determine_version(cls, exe):
|
||||
output = Executable(exe)("--version", output=str, error=str)
|
||||
match = re.match(r"Version\s+([\d.]+)\s*", output)
|
||||
return match.group(1) if match else None
|
||||
|
||||
def install(self, spec, prefix):
|
||||
npm = which("npm", required=True)
|
||||
npm("install", "--global", f"--prefix={prefix}")
|
||||
|
Loading…
Reference in New Issue
Block a user