aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/fs_resolver.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-resolver/src/resolvers/fs_resolver.ts')
-rw-r--r--packages/sol-resolver/src/resolvers/fs_resolver.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/sol-resolver/src/resolvers/fs_resolver.ts b/packages/sol-resolver/src/resolvers/fs_resolver.ts
new file mode 100644
index 000000000..4f05fba88
--- /dev/null
+++ b/packages/sol-resolver/src/resolvers/fs_resolver.ts
@@ -0,0 +1,19 @@
+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;
+ }
+}