Chromium Code Reviews| Index: mojo/public/tools/dart_pub_get.py |
| diff --git a/mojo/public/tools/dart_pub_get.py b/mojo/public/tools/dart_pub_get.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..4a4f12f25dea1d1ccd243eb1c128e3470727ce81 |
| --- /dev/null |
| +++ b/mojo/public/tools/dart_pub_get.py |
| @@ -0,0 +1,34 @@ |
| +#!/usr/bin/python |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +# This script runs "pub get" on a given directory and outputs the filenames of |
|
tonyg
2015/04/08 13:52:38
This looks like a module-level docstring, """Lorem
blundell
2015/04/09 11:53:41
Done.
|
| +# the files that are thus pulled in relative to that given directory. |
|
tonyg
2015/04/08 13:52:38
I think a link to documentation would be helpful i
blundell
2015/04/09 11:53:41
Done.
|
| +# |
| +# The first argument should be the parent directory of the Dart SDK relative to |
| +# the directory in which this script is being run. |
| +# The second argument should be the directory on which to run "pub get" relative |
| +# to the directory in which this script is being run. |
| + |
| +import os |
| +import subprocess |
| +import sys |
| + |
| +def main(args): |
| + dart_sdk_root = args[0] |
|
tonyg
2015/04/08 13:52:38
This is a nit, but I'd recommend using argparse in
blundell
2015/04/09 11:53:41
Done.
|
| + target_directory = args[1] |
| + cmd = [ |
| + os.path.join(os.getcwd(), dart_sdk_root, "dart-sdk/bin/pub") |
|
tonyg
2015/04/08 13:52:38
I could be mistaken, but I don't think os.getcwd()
blundell
2015/04/09 11:53:41
Done.
|
| + ] |
| + cmd.extend(["get"]) |
| + |
| + os.chdir(target_directory) |
| + subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT) |
|
tonyg
2015/04/08 13:52:38
Cleaner to pass cwd=target_dir rather than than do
blundell
2015/04/09 11:53:41
Done.
|
| + |
| + for root, _, files in os.walk("packages", followlinks=True): |
| + for f in files: |
| + print os.path.join(root, f) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv[1:])) |