| 88 | try_remove(options, path, dest) |
| 89 | |
| 90 | def package_files(options, action, name, bins): |
| 91 | target_path = os.path.join('lib/node_modules', name) |
| 92 | |
| 93 | # don't install npm if the target path is a symlink, it probably means |
| 94 | # that a dev version of npm is installed there |
| 95 | if os.path.islink(abspath(options.install_path, target_path)): return |
| 96 | |
| 97 | # npm has a *lot* of files and it'd be a pain to maintain a fixed list here |
| 98 | # so we walk its source directory instead... |
| 99 | root = os.path.join('deps', name) |
| 100 | for dirname, subdirs, basenames in os.walk(root, topdown=True): |
| 101 | subdirs[:] = [subdir for subdir in subdirs if subdir != 'test'] |
| 102 | paths = [os.path.join(dirname, basename) for basename in basenames] |
| 103 | action(options, paths, |
| 104 | os.path.join(target_path, dirname[len(root) + 1:]) + os.path.sep) |
| 105 | |
| 106 | # create/remove symlinks |
| 107 | for bin_name, bin_target in bins.items(): |
| 108 | link_path = abspath(options.install_path, os.path.join('bin', bin_name)) |
| 109 | if action == uninstall: |
| 110 | action(options, [link_path], os.path.join('bin', bin_name)) |
| 111 | elif action == install: |
| 112 | try_symlink(options, os.path.join('../lib/node_modules', name, bin_target), link_path) |
| 113 | else: |
| 114 | assert 0 # unhandled action type |
| 115 | |
| 116 | def npm_files(options, action): |
| 117 | package_files(options, action, 'npm', { |