Merge "Move node_modules install to install-build-deps"
diff --git a/tools/install-build-deps b/tools/install-build-deps
index 2b53158..afa2c89 100755
--- a/tools/install-build-deps
+++ b/tools/install-build-deps
@@ -273,6 +273,12 @@
   subprocess.check_call(['git', 'checkout', revision, '--quiet'], cwd=path)
   assert(IsGitRepoCheckoutOutAtRevision(path, revision))
 
+def InstallNodeModules():
+  ui_dir = os.path.join(ROOT_DIR, 'ui')
+  logging.info("Running npm install in {0}".format(ui_dir))
+  subprocess.check_call(
+    [os.path.join(ui_dir, 'npm'), 'install', '--no-save'],
+    cwd=os.path.join(ROOT_DIR, 'ui'))
 
 def Main():
   parser = argparse.ArgumentParser()
@@ -342,6 +348,9 @@
         stamp_file.write(expected_sha1)
       os.remove(local_path)
 
+  if args.ui:
+    # Needs to happen after nodejs is installed above.
+    InstallNodeModules()
 
 if __name__ == '__main__':
   logging.basicConfig(level=logging.INFO)
diff --git a/ui/BUILD.gn b/ui/BUILD.gn
index 2be5c96..297464d 100644
--- a/ui/BUILD.gn
+++ b/ui/BUILD.gn
@@ -324,7 +324,7 @@
 }
 
 # +----------------------------------------------------------------------------+
-# | Node JS: run npm install and creates a symlink in the out directory.       |
+# | Node JS: Creates a symlink in the out directory to node_modules.           |
 # +----------------------------------------------------------------------------+
 
 action("check_node_exists") {
@@ -362,36 +362,8 @@
   ]
 }
 
-# Runs npm install.
-action("node_modules_install") {
-  script = "../gn/standalone/build_tool_wrapper.py"
-  stamp_file = "$target_out_dir/.$target_name.stamp"
-  args = [
-    "--chdir",
-    rebase_path(".", root_build_dir),
-    "--stamp",
-    rebase_path(stamp_file, root_build_dir),
-  ]
-  args += [
-    "--path=$nodejs_bin",
-    "node",
-    rebase_path("$nodejs_root/bin/npm", "."),
-    "install",
-    "--no-save",
-    "--silent",
-  ]
-  inputs = [
-    "package.json",
-    "package-lock.json",
-  ]
-  outputs = [
-    stamp_file,
-  ]
-}
-
 group("node_modules") {
   deps = [
-    ":node_modules_install",
     ":node_modules_symlink",
   ]
 }
diff --git a/ui/PRESUBMIT.py b/ui/PRESUBMIT.py
index c1b97fe..362bf9a 100644
--- a/ui/PRESUBMIT.py
+++ b/ui/PRESUBMIT.py
@@ -36,6 +36,14 @@
     node = path.join(ui_path, 'node')
     tslint = path.join(ui_path, 'node_modules', '.bin', 'tslint')
 
+    if not path.exists(tslint):
+        repo_root = input_api.change.RepositoryRoot()
+        install_path = path.join(repo_root, 'tools', 'install-build-deps')
+        return [
+            output_api.PresubmitError("Tslint not found. Please first run\n" +
+                "$ {0} --ui".format(install_path))
+        ]
+
     # Some tslint rules require type information and thus need the whole
     # project. We therefore call tslint on the whole project instead of only the
     # changed files. It is possible to break tslint on files that was not