Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: lib/src/flutter.dart

Issue 2174913002: Add an SDK source. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/source/sdk.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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:io'; 5 import 'dart:io';
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:path/path.dart' as p;
8 import 'package:pub_semver/pub_semver.dart'; 8 import 'package:pub_semver/pub_semver.dart';
9 9
10 import 'io.dart'; 10 import 'io.dart';
11 11
12 /// Whether the Flutter SDK is available. 12 /// Whether the Flutter SDK is available.
13 final bool isAvailable = Platform.environment.containsKey("FLUTTER_ROOT"); 13 final bool isAvailable = Platform.environment.containsKey("FLUTTER_ROOT");
14 14
15 /// The path to the root directory of the Flutter SDK. 15 /// The path to the root directory of the Flutter SDK.
16 final String rootDirectory = Platform.environment["FLUTTER_ROOT"]; 16 final String rootDirectory = Platform.environment["FLUTTER_ROOT"];
17 17
18 /// The Flutter SDK's version number, or `null` if the Flutter SDK is 18 /// The Flutter SDK's version number, or `null` if the Flutter SDK is
19 /// unavailable. 19 /// unavailable.
20 final version = () { 20 final version = () {
21 if (!isAvailable) return null; 21 if (!isAvailable) return null;
22 22
23 return new Version.parse( 23 return new Version.parse(
24 readTextFile(p.join(rootDirectory, "version")).trim()); 24 readTextFile(p.join(rootDirectory, "version")).trim());
25 }(); 25 }();
26
27 /// Returns the path to the package [name] within Flutter.
28 String packagePath(String name) {
29 if (!isAvailable) throw new StateError("Flutter is not available.");
30
31 return p.join(rootDirectory, 'packages', name);
32 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/source/sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698