aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/spy_resolver.ts
blob: 3fd62985bea3a6ba0c0688a869cb458f9483a0fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as _ from 'lodash';

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

import { Resolver } from './resolver';

export class SpyResolver extends Resolver {
    public resolvedContractSources: ContractSource[] = [];
    private _resolver: Resolver;
    constructor(resolver: Resolver) {
        super();
        this._resolver = resolver;
    }
    public resolveIfExists(importPath: string): ContractSource | undefined {
        const contractSourceIfExists = this._resolver.resolveIfExists(importPath);
        if (!_.isUndefined(contractSourceIfExists)) {
            this.resolvedContractSources.push(contractSourceIfExists);
        }
        return contractSourceIfExists;
    }
}