OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import '../entrypoint.dart'; | 7 import '../entrypoint.dart'; |
8 import '../validator.dart'; | 8 import '../validator.dart'; |
9 | 9 |
10 /// A validator that validates that a package's SDK constraint doesn't use the | 10 /// A validator that validates that a package's SDK constraint doesn't use the |
11 /// "^" syntax. | 11 /// "^" syntax. |
12 class SdkConstraintValidator extends Validator { | 12 class SdkConstraintValidator extends Validator { |
13 SdkConstraintValidator(Entrypoint entrypoint) | 13 SdkConstraintValidator(Entrypoint entrypoint) |
14 : super(entrypoint); | 14 : super(entrypoint); |
15 | 15 |
16 Future validate() async { | 16 Future validate() async { |
17 var constraint = entrypoint.root.pubspec.environment.sdkVersion; | 17 var constraint = entrypoint.root.pubspec.dartSdkConstraint; |
18 if (!constraint.toString().startsWith("^")) return; | 18 if (!constraint.toString().startsWith("^")) return; |
19 | 19 |
20 errors.add( | 20 errors.add( |
21 "^ version constraints aren't allowed for SDK constraints since " | 21 "^ version constraints aren't allowed for SDK constraints since " |
22 "older versions of pub don't support them.\n" | 22 "older versions of pub don't support them.\n" |
23 "Expand it manually instead:\n" | 23 "Expand it manually instead:\n" |
24 "\n" | 24 "\n" |
25 "environment:\n" | 25 "environment:\n" |
26 " sdk: \">=${constraint.min} <${constraint.max}\""); | 26 " sdk: \">=${constraint.min} <${constraint.max}\""); |
27 } | 27 } |
28 } | 28 } |
OLD | NEW |