aboutsummaryrefslogblamecommitdiffstats
path: root/packages/resolver/src/resolvers/fs_resolver.ts
blob: 4f05fba8880947676c3aed839aa12fc8d54b81b8 (plain) (tree)


















                                                                            
import * as fs from 'fs';

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

import { Resolver } from './resolver';

export class FSResolver extends Resolver {
    // tslint:disable-next-line:prefer-function-over-method
    public resolveIfExists(importPath: string): ContractSource | undefined {
        if (fs.existsSync(importPath)) {
            const fileContent = fs.readFileSync(importPath).toString();
            return {
                source: fileContent,
                path: importPath,
            };
        }
        return undefined;
    }
}