'run-test.py' script should make sure 'node_modules' directory exists before installi...
[WebKit-https.git] / Websites / perf.webkit.org / tools / run-tests.py
index 0398f25..eb58654 100755 (executable)
@@ -10,12 +10,12 @@ def main():
     root_dir = os.path.abspath(os.path.join(tools_dir, '..'))
     node_modules_dir = os.path.join(root_dir, 'node_modules')
 
-    os.chdir(root_dir)
+    os.makedirs(node_modules_dir)
     packages = ['mocha', 'pg', 'form-data']
     for package_name in packages:
         target_dir = os.path.join(node_modules_dir, package_name)
         if not os.path.isdir(target_dir):
-            subprocess.call(['npm', 'install', package_name])
+            subprocess.call(['npm', 'install', package_name], cwd=node_modules_dir)
 
     mocha_path = os.path.join(node_modules_dir, 'mocha/bin/mocha')
     test_paths = sys.argv[1:] or ['unit-tests', 'server-tests']