Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {
// rule order implies precedence. The first rule that matches a given package
// applies to that package, and no other rule does.
let rootsPerRule = new Map();
for (let pkg of activePackages) {
for (let rule of packageRules) {
if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {
let roots = getOrCreate(rootsPerRule, rule, () => []);
roots.push(pkg.root);
break;
}
}
}
let output = [];
for (let [rule, roots] of rootsPerRule) {
output.push(Object.assign({ roots }, rule));
}
return output;
}
private internalSetConfig(fromPath: string, packageName: string | undefined, config: unknown) {
if (this.cachedUserConfigs) {
throw new Error(`attempted to set config after we have already emitted our config`);
}
let targetPackage = this.resolvePackage(fromPath, packageName);
let peers = getOrCreate(this.configs, targetPackage.root, () => []);
peers.push(config);
}
private addAddon(addonInstance: any) {
let Klass = this.adapterClass(addonInstance.pkg.name);
let v1Addon = new Klass(addonInstance, this.options, this.app);
let pkgs = getOrCreate(this.addons, v1Addon.root, () => []);
pkgs.push(v1Addon);
(addonInstance.addons as any[]).forEach(a => this.addAddon(a));
}
static forApp(emberApp: object, options: Required): V1InstanceCache {
let instance = getOrCreate(this.caches, emberApp, () => new this(emberApp, options));
if (options && !isEqual(instance.options, options)) {
throw new Error(`attempted double set of app Options`);
}
return instance;
}