blob: 2317ede8364a53f6715262ef1470f62a3ffc8602 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import * as fs from 'fs';
import * as path from 'path';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class RelativeFSResolver extends Resolver {
private _contractsDir: string;
constructor(contractsDir: string) {
super();
this._contractsDir = contractsDir;
}
// tslint:disable-next-line:prefer-function-over-method
public resolveIfExists(importPath: string): ContractSource | undefined {
const filePath = path.join(this._contractsDir, importPath);
if (fs.existsSync(filePath)) {
const fileContent = fs.readFileSync(filePath).toString();
return {
source: fileContent,
path: importPath,
};
}
return undefined;
}
}
|