blob: ef300e6dbad48552947f6e58bfbeb9468a7c43c7 (
plain) (
tree)
|
|
import * as fs from 'fs';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class URLResolver extends Resolver {
// tslint:disable-next-line:prefer-function-over-method
public resolveIfExists(importPath: string): ContractSource | undefined {
const FILE_URL_PREXIF = 'file://';
if (importPath.startsWith(FILE_URL_PREXIF)) {
const filePath = importPath.substr(FILE_URL_PREXIF.length);
const fileContent = fs.readFileSync(filePath).toString();
return { source: fileContent, path: importPath, absolutePath: filePath };
}
return undefined;
}
}
|