blob: fd398426287203e298fd896bdc1e93c75000bf99 [file] [log] [blame]
// Copyright (c) 2020, 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.
//
// @dart=2.7
import 'package:package_config/package_config.dart';
/// Adds methods to convert to a package map on [PackageConfig].
extension PackageMap on PackageConfig {
/// A package map exactly matching the current package config
Map<String, Uri> toPackageMap() =>
{for (var package in packages) package.name: package.packageUriRoot};
/// A package map with all the current packages but where the uris are all
/// of the form 'packages/${package.name}'.
Map<String, Uri> toPackagesDirPackageMap() => {
for (var package in packages)
package.name: Uri.parse('packages/${package.name}')
};
}