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 /// Operations relative to the user's installed Dart SDK. | 5 /// Operations relative to the user's installed Dart SDK. |
6 library sdk; | 6 library sdk; |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import '../../pkg/path/lib/path.dart' as path; | 10 import '../../pkg/path/lib/path.dart' as path; |
(...skipping 27 matching lines...) Expand all Loading... |
38 /// Determine the SDK's version number. | 38 /// Determine the SDK's version number. |
39 Version _getVersion() { | 39 Version _getVersion() { |
40 var revisionPath = path.join(rootDirectory, "version"); | 40 var revisionPath = path.join(rootDirectory, "version"); |
41 var version = new File(revisionPath).readAsStringSync().trim(); | 41 var version = new File(revisionPath).readAsStringSync().trim(); |
42 | 42 |
43 // Given a version file like: 0.1.2.0_r17495 | 43 // Given a version file like: 0.1.2.0_r17495 |
44 // We create a semver like: 0.1.2+0._r17495 | 44 // We create a semver like: 0.1.2+0._r17495 |
45 var match = _versionPattern.firstMatch(version); | 45 var match = _versionPattern.firstMatch(version); |
46 if (match == null) { | 46 if (match == null) { |
47 throw new FormatException("The Dart SDK's 'version' file was not in a " | 47 throw new FormatException("The Dart SDK's 'version' file was not in a " |
48 "format pub could recognize. Found: $revision"); | 48 "format pub could recognize. Found: $version"); |
49 } | 49 } |
50 | 50 |
51 var build = match[4]; | 51 var build = match[4]; |
52 if (match[5].length > 0) build = '$build.${match[5]}'; | 52 if (match[5].length > 0) build = '$build.${match[5]}'; |
53 | 53 |
54 return new Version( | 54 return new Version( |
55 int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), | 55 int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), |
56 build: build); | 56 build: build); |
57 } | 57 } |
OLD | NEW |