This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Packages interface class should not depend on a platform specific library (dart:io). This removed the dependency, and also splits the implementation classes into those that are generally applicable and those that requite dart:io to operate (the "local packages directory" which allows iterating the package names by scanning the directory). Bump version to 0.0.2+4
- Loading branch information
1 parent
f77f208
commit 99afb4d
Showing
6 changed files
with
51 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// Implementations of [Packages] that can only be used in server based | ||
/// applications. | ||
library package_config.packages_io_impl; | ||
|
||
import "dart:collection" show UnmodifiableMapView; | ||
import "dart:io" show Directory; | ||
import "package:path/path.dart" as path; | ||
import "packages_impl.dart"; | ||
|
||
/// A [Packages] implementation based on a local directory. | ||
class FilePackagesDirectoryPackages extends PackagesBase { | ||
final Directory _packageDir; | ||
FilePackagesDirectoryPackages(this._packageDir); | ||
|
||
Uri getBase(String packageName) => | ||
new Uri.file(path.join(_packageDir.path, packageName, '.')); | ||
|
||
Iterable<String> _listPackageNames() { | ||
return _packageDir.listSync() | ||
.where((e) => e is Directory) | ||
.map((e) => path.basename(e.path)); | ||
} | ||
|
||
Iterable<String> get packages => _listPackageNames(); | ||
|
||
Map<String, Uri> asMap() { | ||
var result = <String, Uri>{}; | ||
for (var packageName in _listPackageNames()) { | ||
result[packageName] = getBase(packageName); | ||
} | ||
return new UnmodifiableMapView<String, Uri>(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: package_config | ||
version: 0.0.2+4 | ||
version: 0.0.3 | ||
description: Support for working with Package Resolution config files. | ||
author: Dart Team <[email protected]> | ||
homepage: https://github.com/dart-lang/package_config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters