| 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 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 var pubDir = path.dirname(new Options().script); | 31 var pubDir = path.dirname(new Options().script); |
| 32 dir = path.normalize(path.join(pubDir, "../../")); | 32 dir = path.normalize(path.join(pubDir, "../../")); |
| 33 log.fine("Located SDK at $dir"); | 33 log.fine("Located SDK at $dir"); |
| 34 return dir; | 34 return dir; |
| 35 } | 35 } |
| 36 | 36 |
| 37 /// 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. |
| 38 Version version = _getVersion(); | 38 Version version = _getVersion(); |
| 39 | 39 |
| 40 /// Is `true` if the current SDK is an unreleased bleeding edge version. |
| 41 bool get isBleedingEdge { |
| 42 // The live build is locked to the magical old number "0.1.2+<stuff>". |
| 43 return version.major == 0 && version.minor == 1 && version.patch == 2; |
| 44 } |
| 45 |
| 40 /// Determine the SDK's version number. | 46 /// Determine the SDK's version number. |
| 41 Version _getVersion() { | 47 Version _getVersion() { |
| 42 var revisionPath = path.join(rootDirectory, "version"); | 48 var revisionPath = path.join(rootDirectory, "version"); |
| 43 var version = readTextFile(revisionPath).trim(); | 49 var version = readTextFile(revisionPath).trim(); |
| 44 | 50 |
| 45 // Given a version file like: 0.1.2.0_r17495 | 51 // Given a version file like: 0.1.2.0_r17495 |
| 46 // We create a semver like: 0.1.2+0.r17495 | 52 // We create a semver like: 0.1.2+0.r17495 |
| 47 var match = _versionPattern.firstMatch(version); | 53 var match = _versionPattern.firstMatch(version); |
| 48 if (match == null) { | 54 if (match == null) { |
| 49 throw new FormatException("The Dart SDK's 'version' file was not in a " | 55 throw new FormatException("The Dart SDK's 'version' file was not in a " |
| 50 "format pub could recognize. Found: $version"); | 56 "format pub could recognize. Found: $version"); |
| 51 } | 57 } |
| 52 | 58 |
| 53 // Semantic versions cannot use "_". | 59 // Semantic versions cannot use "_". |
| 54 var build = match[4].replaceAll('_', '.'); | 60 var build = match[4].replaceAll('_', '.'); |
| 55 | 61 |
| 56 return new Version( | 62 return new Version( |
| 57 int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), | 63 int.parse(match[1]), int.parse(match[2]), int.parse(match[3]), |
| 58 build: build); | 64 build: build); |
| 59 } | 65 } |
| OLD | NEW |