| 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 library leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 Future setupPackages(Uri uri) { | 385 Future setupPackages(Uri uri) { |
| 386 if (packageRoot != null) { | 386 if (packageRoot != null) { |
| 387 // Use "non-file" packages because the file version requires a [Directory] | 387 // Use "non-file" packages because the file version requires a [Directory] |
| 388 // and we can't depend on 'dart:io' classes. | 388 // and we can't depend on 'dart:io' classes. |
| 389 packages = new NonFilePackagesDirectoryPackages(packageRoot); | 389 packages = new NonFilePackagesDirectoryPackages(packageRoot); |
| 390 } else if (packageConfig != null) { | 390 } else if (packageConfig != null) { |
| 391 return callUserProvider(packageConfig).then((packageConfigContents) { | 391 return callUserProvider(packageConfig).then((packageConfigContents) { |
| 392 if (packageConfigContents is String) { | 392 if (packageConfigContents is String) { |
| 393 packageConfigContents = UTF8.encode(packageConfigContents); | 393 packageConfigContents = UTF8.encode(packageConfigContents); |
| 394 } | 394 } |
| 395 // The input provider may put a trailing 0 byte when it reads a source |
| 396 // file, which confuses the package config parser. |
| 397 if (packageConfigContents.length > 0 |
| 398 && packageConfigContents.last == 0) { |
| 399 packageConfigContents = packageConfigContents.sublist( |
| 400 0, packageConfigContents.length - 1); |
| 401 } |
| 395 packages = | 402 packages = |
| 396 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); | 403 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); |
| 397 }); | 404 }); |
| 398 } else { | 405 } else { |
| 399 if (packagesDiscoveryProvider == null) { | 406 if (packagesDiscoveryProvider == null) { |
| 400 packages = Packages.noPackages; | 407 packages = Packages.noPackages; |
| 401 } else { | 408 } else { |
| 402 return callUserPackagesDiscovery(uri).then((p) { | 409 return callUserPackagesDiscovery(uri).then((p) { |
| 403 packages = p; | 410 packages = p; |
| 404 }); | 411 }); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 print('$message: ${tryToString(exception)}'); | 498 print('$message: ${tryToString(exception)}'); |
| 492 print(tryToString(stackTrace)); | 499 print(tryToString(stackTrace)); |
| 493 } | 500 } |
| 494 | 501 |
| 495 fromEnvironment(String name) => environment[name]; | 502 fromEnvironment(String name) => environment[name]; |
| 496 | 503 |
| 497 LibraryInfo lookupLibraryInfo(String libraryName) { | 504 LibraryInfo lookupLibraryInfo(String libraryName) { |
| 498 return library_info.LIBRARIES[libraryName]; | 505 return library_info.LIBRARIES[libraryName]; |
| 499 } | 506 } |
| 500 } | 507 } |
| OLD | NEW |