%nodejs_symlink_deps improvements

-support installing multiple modules from the same SRPM
-drop name argument rendered useless by the above
-support a --check argument that works in the current working directory
 instead of $RPM_BUILD_ROOT
This commit is contained in:
T.C. Hollingsworth 2013-03-31 21:26:43 -07:00
parent 7cb1934a64
commit b22ee6fcc9
2 changed files with 23 additions and 17 deletions

View File

@ -3,7 +3,7 @@
"""Symlink a node module's dependencies into the node_modules directory so users
can `npm link` RPM-installed modules into their personal projects."""
# Copyright 2012 T.C. Hollingsworth <tchollingsworth@gmail.com>
# Copyright 2012, 2013 T.C. Hollingsworth <tchollingsworth@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
@ -30,23 +30,26 @@ import sys
#the %nodejs_symlink_deps macro passes %nodejs_sitelib as the first argument
sitelib = sys.argv[1]
metadata = json.load(open('package.json'))
if len(sys.argv) > 2:
name = sys.argv[2]
if '--check' in sys.argv:
check = True
modules = [os.getcwd()]
else:
name = metadata['name']
check = False
br_sitelib = os.path.join(os.environ['RPM_BUILD_ROOT'], sitelib.lstrip('/'))
modules = [os.path.join(br_sitelib, module) for module in os.listdir(br_sitelib)]
os.chdir(os.path.join(os.environ['RPM_BUILD_ROOT'], sitelib.lstrip('/'), name))
for path in modules:
os.chdir(path)
md = json.load(open('package.json'))
if 'dependencies' in md:
try:
os.mkdir('node_modules')
except OSError:
sys.stderr.write('WARNING: node_modules already exists. Make sure you have ' +
'no bundled dependencies.\n')
if 'dependencies' in metadata:
try:
os.mkdir('node_modules')
except OSError:
sys.stderr.write('WARNING: node_modules already exists. Make sure you have ' +
'no bundled dependencies.\n')
os.chdir('node_modules')
os.chdir('node_modules')
for dep in metadata['dependencies'].iterkeys():
os.symlink(os.path.join(sitelib, dep), dep)
for dep in md['dependencies'].iterkeys():
os.symlink(os.path.join(sitelib, dep), dep)

View File

@ -194,6 +194,9 @@ cp -p common.gypi %{buildroot}%{_datadir}/node
- remove %%nodejs_arches macro since it will only be useful if it is present in
the redhat-rpm-config package
- add default filtering macro to remove unwanted Provides from native modules
- nodejs-symlink-deps now supports multiple modules in one SRPM properly
- nodejs-symlink-deps also now supports a --check argument that works in the
current working directry instead of the buildroot
* Fri Mar 22 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.10.1-1
- new upstream release 0.10.1