| 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; | 
 |  11  | 
 |  12 import 'io.dart'; | 
|  11 import 'log.dart' as log; |  13 import 'log.dart' as log; | 
|  12 import 'version.dart'; |  14 import 'version.dart'; | 
|  13  |  15  | 
|  14 /// Matches an Eclipse-style SDK version number. This is four dotted numbers |  16 /// Matches an Eclipse-style SDK version number. This is four dotted numbers | 
|  15 /// (major, minor, patch, build) with an optional suffix attached to the build |  17 /// (major, minor, patch, build) with an optional suffix attached to the build | 
|  16 /// number. |  18 /// number. | 
|  17 final _versionPattern = new RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+.*)$'); |  19 final _versionPattern = new RegExp(r'^(\d+)\.(\d+)\.(\d+)\.(\d+.*)$'); | 
|  18  |  20  | 
|  19 /// Gets the path to the root directory of the SDK. |  21 /// Gets the path to the root directory of the SDK. | 
|  20 String get rootDirectory { |  22 String get rootDirectory { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  31   log.fine("Located SDK at $dir"); |  33   log.fine("Located SDK at $dir"); | 
|  32   return dir; |  34   return dir; | 
|  33 } |  35 } | 
|  34  |  36  | 
|  35 /// Gets the SDK's revision number formatted to be a semantic version. |  37 /// Gets the SDK's revision number formatted to be a semantic version. | 
|  36 Version version = _getVersion(); |  38 Version version = _getVersion(); | 
|  37  |  39  | 
|  38 /// Determine the SDK's version number. |  40 /// Determine the SDK's version number. | 
|  39 Version _getVersion() { |  41 Version _getVersion() { | 
|  40   var revisionPath = path.join(rootDirectory, "version"); |  42   var revisionPath = path.join(rootDirectory, "version"); | 
|  41   var version = new File(revisionPath).readAsStringSync().trim(); |  43   var version = readTextFile(revisionPath).trim(); | 
|  42  |  44  | 
|  43   // Given a version file like: 0.1.2.0_r17495 |  45   // Given a version file like: 0.1.2.0_r17495 | 
|  44   // We create a semver like:   0.1.2+0.r17495 |  46   // We create a semver like:   0.1.2+0.r17495 | 
|  45   var match = _versionPattern.firstMatch(version); |  47   var match = _versionPattern.firstMatch(version); | 
|  46   if (match == null) { |  48   if (match == null) { | 
|  47     throw new FormatException("The Dart SDK's 'version' file was not in a " |  49     throw new FormatException("The Dart SDK's 'version' file was not in a " | 
|  48         "format pub could recognize. Found: $version"); |  50         "format pub could recognize. Found: $version"); | 
|  49   } |  51   } | 
|  50  |  52  | 
|  51   // Semantic versions cannot use "_". |  53   // Semantic versions cannot use "_". | 
|  52   var build = match[4].replaceAll('_', '.'); |  54   var build = match[4].replaceAll('_', '.'); | 
|  53  |  55  | 
|  54   return new Version( |  56   return new Version( | 
|  55       int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), |  57       int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), | 
|  56       build: build); |  58       build: build); | 
|  57 } |  59 } | 
| OLD | NEW |