| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Utility for updating third_party packages used in the Mojo Dart SDK""" | 7 """Utility for updating third_party packages used in the Mojo Dart SDK""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import errno | 10 import errno |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 print('Copying %s to %s' % (package_path, destinaton_path)) | 48 print('Copying %s to %s' % (package_path, destinaton_path)) |
| 49 shutil.copytree(package_path, destinaton_path) | 49 shutil.copytree(package_path, destinaton_path) |
| 50 | 50 |
| 51 def cleanup(base_path): | 51 def cleanup(base_path): |
| 52 shutil.rmtree(os.path.join(base_path, 'packages'), True) | 52 shutil.rmtree(os.path.join(base_path, 'packages'), True) |
| 53 shutil.rmtree(os.path.join(base_path, '.pub'), True) | 53 shutil.rmtree(os.path.join(base_path, '.pub'), True) |
| 54 os.remove(os.path.join(base_path, '.packages')) | 54 os.remove(os.path.join(base_path, '.packages')) |
| 55 | 55 |
| 56 def main(): | 56 def main(): |
| 57 parser = argparse.ArgumentParser(description='Update third_party packages') | 57 parser = argparse.ArgumentParser(description='Update third_party packages') |
| 58 parser.add_argument('--pub-exe', | 58 parser.add_argument( |
| 59 action='store', | 59 '--pub-exe', |
| 60 metavar='pub_exe', | 60 action='store', |
| 61 help='Path to the pub executable', | 61 metavar='pub_exe', |
| 62 default='../../../../third_party/dart-sdk/dart-sdk/bin/pub
') | 62 help='Path to the pub executable', |
| 63 default='../../../../third_party/dart-sdk/dart-sdk/bin/pub') |
| 63 parser.add_argument('--directory', | 64 parser.add_argument('--directory', |
| 64 action='store', | 65 action='store', |
| 65 metavar='directory', | 66 metavar='directory', |
| 66 help='Directory containing pubspec.yaml', | 67 help='Directory containing pubspec.yaml', |
| 67 default='.') | 68 default='.') |
| 68 parser.add_argument('--list', | 69 parser.add_argument('--list', |
| 69 help='List mode', | 70 help='List mode', |
| 70 action='store_true', | 71 action='store_true', |
| 71 default=False) | 72 default=False) |
| 72 args = parser.parse_args() | 73 args = parser.parse_args() |
| 73 args.directory = os.path.abspath(args.directory) | 74 args.directory = os.path.abspath(args.directory) |
| 74 | 75 |
| 75 if not check_for_pubspec_yaml(args.directory): | 76 if not check_for_pubspec_yaml(args.directory): |
| 76 print('Error could not find pubspec.yaml') | 77 print('Error could not find pubspec.yaml') |
| 77 return 1 | 78 return 1 |
| 78 | 79 |
| 79 if args.list: | 80 if args.list: |
| 80 list_packages(args.directory) | 81 list_packages(args.directory) |
| 81 else: | 82 else: |
| 82 remove_existing_packages(args.directory) | 83 remove_existing_packages(args.directory) |
| 83 change_directory(args.directory) | 84 change_directory(args.directory) |
| 84 print('Running pub get') | 85 print('Running pub get') |
| 85 pub_get(args.pub_exe) | 86 pub_get(args.pub_exe) |
| 86 copy_packages(args.directory) | 87 copy_packages(args.directory) |
| 87 print('Cleaning up') | 88 print('Cleaning up') |
| 88 cleanup(args.directory) | 89 cleanup(args.directory) |
| 89 | 90 |
| 90 if __name__ == '__main__': | 91 if __name__ == '__main__': |
| 91 sys.exit(main()) | 92 sys.exit(main()) |
| OLD | NEW |