mirror of https://github.com/clickscodes/nucleus
parent
9b6992a7a6
commit
3021937052
@ -1,4 +1,4 @@
|
||||
[submodule "src/reflex/nsfwjs"]
|
||||
path = src/reflex/nsfwjs
|
||||
url = https://github.com/infinitered/nsfwjs
|
||||
url = https://github.com/clicksminuteper/nsfwjs
|
||||
shallow = true
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
||||
node_modules = sys.argv[1]
|
||||
bin_dir = sys.argv[2]
|
||||
|
||||
def collect_packages_in(_node_modules, packages: set[str] | None = None):
|
||||
_packages: set[str] = packages or set()
|
||||
for path in os.listdir(_node_modules):
|
||||
if not os.path.isdir(os.path.join(_node_modules, path)) or os.path.join(_node_modules, path) in _packages:
|
||||
continue
|
||||
|
||||
_packages.add(os.path.join(_node_modules, path))
|
||||
if os.path.exists(os.path.join(_node_modules, path, "node_modules")):
|
||||
collect_packages_in(os.path.join(_node_modules, path, "node_modules"), _packages)
|
||||
return _packages
|
||||
|
||||
def get_binaries_in(package):
|
||||
package_json = os.path.join(package, "package.json")
|
||||
if not os.path.exists(package_json):
|
||||
return []
|
||||
|
||||
with open(package_json) as f:
|
||||
package_json_contents = json.load(f)
|
||||
|
||||
if "bin" not in package_json_contents:
|
||||
return []
|
||||
|
||||
if type(package_json_contents["bin"]) == str:
|
||||
return [[os.path.basename(package_json_contents["name"]), os.path.join(package, package_json_contents["bin"])]]
|
||||
|
||||
return [[name, os.path.join(package, bin)] for name, bin in package_json_contents["bin"].items()]
|
||||
|
||||
def main():
|
||||
packages = collect_packages_in(node_modules)
|
||||
binaries = []
|
||||
for package in packages:
|
||||
binaries += get_binaries_in(package)
|
||||
|
||||
os.makedirs(bin_dir, exist_ok=True)
|
||||
|
||||
for binary in binaries:
|
||||
if os.path.exists(os.path.join(bin_dir, binary[0])):
|
||||
os.remove(os.path.join(bin_dir, binary[0]))
|
||||
|
||||
os.symlink(os.path.realpath(binary[1]), os.path.join(bin_dir, binary[0]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -0,0 +1 @@
|
||||
Subproject commit 9b0e45c13996b1b6bc96a3af3d3c4b67ad4e971f
|
||||
Loading…
Reference in new issue