aboutsummaryrefslogblamecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/fallthrough_resolver.ts
blob: 8f6af9be0661cbafe49ad3c68f89146bc52837ed (plain) (tree)




















                                                                                
import * as _ from 'lodash';

import { ContractSource } from '../types';

import { Resolver } from './resolver';

export class FallthroughResolver extends Resolver {
    private _resolvers: Resolver[] = [];
    public appendResolver(resolver: Resolver): void {
        this._resolvers.push(resolver);
    }
    public resolveIfExists(importPath: string): ContractSource | undefined {
        for (const resolver of this._resolvers) {
            const contractSourceIfExists = resolver.resolveIfExists(importPath);
            if (!_.isUndefined(contractSourceIfExists)) {
                return contractSourceIfExists;
            }
        }
        return undefined;
    }
}