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 library pub.global_packages; | 5 library pub.global_packages; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 new File(oldLockFilePath).renameSync(lockFilePath); | 301 new File(oldLockFilePath).renameSync(lockFilePath); |
302 } | 302 } |
303 | 303 |
304 // Remove the package itself from the lockfile. We put it in there so we | 304 // Remove the package itself from the lockfile. We put it in there so we |
305 // could find and load the [Package] object, but normally an entrypoint | 305 // could find and load the [Package] object, but normally an entrypoint |
306 // doesn't expect to be in its own lockfile. | 306 // doesn't expect to be in its own lockfile. |
307 var id = lockFile.packages[name]; | 307 var id = lockFile.packages[name]; |
308 lockFile = lockFile.removePackage(name); | 308 lockFile = lockFile.removePackage(name); |
309 | 309 |
310 var source = cache.sources[id.source]; | 310 var source = cache.sources[id.source]; |
| 311 var entrypoint; |
311 if (source is CachedSource) { | 312 if (source is CachedSource) { |
312 // For cached sources, the package itself is in the cache and the | 313 // For cached sources, the package itself is in the cache and the |
313 // lockfile is the one we just loaded. | 314 // lockfile is the one we just loaded. |
314 var dir = cache.sources[id.source].getDirectory(id); | 315 var dir = cache.sources[id.source].getDirectory(id); |
315 var package = new Package.load(name, dir, cache.sources); | 316 var package = new Package.load(name, dir, cache.sources); |
316 return new Entrypoint.inMemory(package, lockFile, cache, isGlobal: true); | 317 entrypoint = new Entrypoint.inMemory( |
| 318 package, lockFile, cache, isGlobal: true); |
| 319 } else { |
| 320 // For uncached sources (i.e. path), the ID just points to the real |
| 321 // directory for the package. |
| 322 assert(id.source == "path"); |
| 323 entrypoint = new Entrypoint( |
| 324 PathSource.pathFromDescription(id.description), cache, |
| 325 isGlobal: true); |
317 } | 326 } |
318 | 327 |
319 // For uncached sources (i.e. path), the ID just points to the real | 328 if (entrypoint.root.pubspec.environment.sdkVersion.allows(sdk.version)) { |
320 // directory for the package. | 329 return entrypoint; |
321 assert(id.source == "path"); | 330 } |
322 return new Entrypoint( | 331 |
323 PathSource.pathFromDescription(id.description), cache, isGlobal: true); | 332 dataError("${log.bold(name)} ${entrypoint.root.version} doesn't support " |
| 333 "Dart ${sdk.version}."); |
324 } | 334 } |
325 | 335 |
326 /// Runs [package]'s [executable] with [args]. | 336 /// Runs [package]'s [executable] with [args]. |
327 /// | 337 /// |
328 /// If [executable] is available in its precompiled form, that will be | 338 /// If [executable] is available in its precompiled form, that will be |
329 /// recompiled if the SDK has been upgraded since it was first compiled and | 339 /// recompiled if the SDK has been upgraded since it was first compiled and |
330 /// then run. Otherwise, it will be run from source. | 340 /// then run. Otherwise, it will be run from source. |
331 /// | 341 /// |
332 /// If [checked] is true, the program is run in checked mode. If [mode] is | 342 /// If [checked] is true, the program is run in checked mode. If [mode] is |
333 /// passed, it's used as the barback mode; it defaults to | 343 /// passed, it's used as the barback mode; it defaults to |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 794 } |
785 | 795 |
786 /// Returns the value of the property named [name] in the bin stub script | 796 /// Returns the value of the property named [name] in the bin stub script |
787 /// [source]. | 797 /// [source]. |
788 String _binStubProperty(String source, String name) { | 798 String _binStubProperty(String source, String name) { |
789 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); | 799 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); |
790 var match = pattern.firstMatch(source); | 800 var match = pattern.firstMatch(source); |
791 return match == null ? null : match[1]; | 801 return match == null ? null : match[1]; |
792 } | 802 } |
793 } | 803 } |
OLD | NEW |