aboutsummaryrefslogtreecommitdiffstats
path: root/packages/resolver/src/resolvers/resolver.ts
blob: 7edc9a85d4c1eba962b77619ee0e8c5c4f267620 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import * as _ from 'lodash';

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

export abstract class Resolver {
    public abstract resolveIfExists(importPath: string): ContractSource | undefined;
    public resolve(importPath: string): ContractSource {
        const contractSourceIfExists = this.resolveIfExists(importPath);
        if (_.isUndefined(contractSourceIfExists)) {
            throw new Error(`Failed to resolve ${importPath}`);
        }
        return contractSourceIfExists;
    }
}