aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/relative_fs_resolver.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-05-09 02:04:31 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-05-09 02:04:31 +0800
commit607d738342a839788b59e0dee63849ea447331bc (patch)
treed90078ec0e95357a2fe9fb4af65f9135e9e44408 /packages/sol-resolver/src/resolvers/relative_fs_resolver.ts
parentb8c611de2b82657a274c55007ffc5d72807eae7f (diff)
parente9d70b7b1edb5089a6e5e2a9ee8c964ab4b4d4ab (diff)
downloaddexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar.gz
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar.bz2
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar.lz
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar.xz
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.tar.zst
dexon-0x-contracts-607d738342a839788b59e0dee63849ea447331bc.zip
Merge branch 'development' into feature/website/top-bar-redesign
* development: (63 commits) Update The Ocean logo Fix artifacts paths Create an artifacts folder Introduce a var Add removeHexPrefix util method CHeck if ABI exists Improve the readability of the check for should compile Use named constants Add a comment Fix comments Rename args to constructor-args Fix a typo Define a separator const Move artifacts from src/artifacts to artifacts/v1 Fix sol-cov to work with the new artifacts format Implement new artifacts format Publish Updated CHANGELOGS Make node types a dependency Fix type errors in CSS properties ...
Diffstat (limited to 'packages/sol-resolver/src/resolvers/relative_fs_resolver.ts')
-rw-r--r--packages/sol-resolver/src/resolvers/relative_fs_resolver.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/sol-resolver/src/resolvers/relative_fs_resolver.ts b/packages/sol-resolver/src/resolvers/relative_fs_resolver.ts
new file mode 100644
index 000000000..2317ede83
--- /dev/null
+++ b/packages/sol-resolver/src/resolvers/relative_fs_resolver.ts
@@ -0,0 +1,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;
+ }
+}