diff --git a/nodejs-symlink-deps b/nodejs-symlink-deps index f5636bb..e53e8e5 100755 --- a/nodejs-symlink-deps +++ b/nodejs-symlink-deps @@ -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 +# Copyright 2012, 2013 T.C. Hollingsworth # # 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) diff --git a/nodejs.spec b/nodejs.spec index daf9e31..dc76fc1 100644 --- a/nodejs.spec +++ b/nodejs.spec @@ -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 - 0.10.1-1 - new upstream release 0.10.1