|
19 | 19 | from pre_commit.util import clean_path_on_failure |
20 | 20 | from pre_commit.util import cmd_output |
21 | 21 | from pre_commit.util import cmd_output_b |
| 22 | +from pre_commit.util import rmtree |
22 | 23 |
|
23 | 24 | ENVIRONMENT_DIR = 'node_env' |
24 | 25 |
|
@@ -99,11 +100,23 @@ def install_environment( |
99 | 100 | with in_env(prefix, version): |
100 | 101 | # https://npm.community/t/npm-install-g-git-vs-git-clone-cd-npm-install-g/5449 |
101 | 102 | # install as if we installed from git |
102 | | - helpers.run_setup_cmd(prefix, ('npm', 'install')) |
103 | | - helpers.run_setup_cmd( |
104 | | - prefix, |
105 | | - ('npm', 'install', '-g', '.', *additional_dependencies), |
| 103 | + |
| 104 | + local_install_cmd = ( |
| 105 | + 'npm', 'install', '--dev', '--prod', |
| 106 | + '--ignore-prepublish', '--no-progress', '--no-save', |
106 | 107 | ) |
| 108 | + helpers.run_setup_cmd(prefix, local_install_cmd) |
| 109 | + |
| 110 | + _, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir) |
| 111 | + pkg = prefix.path(pkg.strip()) |
| 112 | + |
| 113 | + install = ('npm', 'install', '-g', pkg, *additional_dependencies) |
| 114 | + helpers.run_setup_cmd(prefix, install) |
| 115 | + |
| 116 | + # clean these up after installation |
| 117 | + if prefix.exists('node_modules'): # pragma: win32 no cover |
| 118 | + rmtree(prefix.path('node_modules')) |
| 119 | + os.remove(pkg) |
107 | 120 |
|
108 | 121 |
|
109 | 122 | def run_hook( |
|
0 commit comments