OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
6 library pub.utils; | 6 library pub.utils; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import "dart:convert"; | 9 import "dart:convert"; |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 | 11 |
12 import "package:crypto/crypto.dart"; | 12 import "package:crypto/crypto.dart"; |
13 import 'package:path/path.dart' as path; | 13 import 'package:path/path.dart' as path; |
14 import "package:stack_trace/stack_trace.dart"; | 14 import "package:stack_trace/stack_trace.dart"; |
15 | 15 |
16 import 'exceptions.dart'; | 16 import 'exceptions.dart'; |
17 import 'io.dart'; | 17 import 'io.dart'; |
18 import 'log.dart' as log; | 18 import 'log.dart' as log; |
19 | 19 |
20 export '../../asset/dart/utils.dart'; | 20 export 'asset/dart/utils.dart'; |
21 | 21 |
22 /// A regular expression matching a Dart identifier. | 22 /// A regular expression matching a Dart identifier. |
23 /// | 23 /// |
24 /// This also matches a package name, since they must be Dart identifiers. | 24 /// This also matches a package name, since they must be Dart identifiers. |
25 final identifierRegExp = new RegExp(r"[a-zA-Z_][a-zA-Z0-9_]+"); | 25 final identifierRegExp = new RegExp(r"[a-zA-Z_][a-zA-Z0-9_]+"); |
26 | 26 |
27 /// Like [identifierRegExp], but anchored so that it only matches strings that | 27 /// Like [identifierRegExp], but anchored so that it only matches strings that |
28 /// are *just* Dart identifiers. | 28 /// are *just* Dart identifiers. |
29 final onlyIdentifierRegExp = new RegExp("^${identifierRegExp.pattern}\$"); | 29 final onlyIdentifierRegExp = new RegExp("^${identifierRegExp.pattern}\$"); |
30 | 30 |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 } else { | 919 } else { |
920 throw new ApplicationException(message); | 920 throw new ApplicationException(message); |
921 } | 921 } |
922 } | 922 } |
923 | 923 |
924 /// Throw a [DataException] with [message] to indicate that the command has | 924 /// Throw a [DataException] with [message] to indicate that the command has |
925 /// failed because of invalid input data. | 925 /// failed because of invalid input data. |
926 /// | 926 /// |
927 /// This will report the error and cause pub to exit with [exit_codes.DATA]. | 927 /// This will report the error and cause pub to exit with [exit_codes.DATA]. |
928 void dataError(String message) => throw new DataException(message); | 928 void dataError(String message) => throw new DataException(message); |
OLD | NEW |