Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2019 The Chromium Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | import json |
| 10 | import devtools_paths |
| 11 | |
| 12 | |
| 13 | def run_assert(): |
| 14 | assert_errors_found = False |
| 15 | try: |
| 16 | with open(devtools_paths.package_json_path(), 'r') as pkg_file: |
| 17 | pkg = json.load(pkg_file) |
| 18 | if 'dependencies' in pkg: |
| 19 | print('dependencies property found in package.json') |
| 20 | assert_errors_found = True |
| 21 | if 'devDependencies' in pkg: |
| 22 | print('devDependencies property found in package.json') |
| 23 | assert_errors_found = True |
| 24 | except ValueError: |
| 25 | print('Unable to parse package.json') |
| 26 | assert_errors_found = True |
| 27 | except FileNotFoundError: |
| 28 | print('Unable to find package.json') |
| 29 | assert_errors_found = True |
| 30 | |
| 31 | return assert_errors_found |
| 32 | |
| 33 | |
| 34 | errors_found = run_assert() |
| 35 | |
| 36 | if errors_found: |
| 37 | print("ERRORS DETECTED") |
| 38 | sys.exit(1) |