diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-17 02:47:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 02:47:28 +0800 |
commit | d263f7783fabe89cc9714b596068eccdc5babc1c (patch) | |
tree | 54a5c8f0a88320f3df8330d95506aea96e808bd3 /packages/sol-resolver/src/resolvers/url_resolver.ts | |
parent | 1fcf3c5dc44d10648e14d6b10c174930eecf27b1 (diff) | |
parent | d8ef76fd5efe63ec8f6205a73494ce388e64391f (diff) | |
download | dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.gz dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.bz2 dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.lz dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.xz dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.tar.zst dexon-0x-contracts-d263f7783fabe89cc9714b596068eccdc5babc1c.zip |
Merge pull request #512 from 0xProject/feature/resolver
Dependencies resolver for deployer
Diffstat (limited to 'packages/sol-resolver/src/resolvers/url_resolver.ts')
-rw-r--r-- | packages/sol-resolver/src/resolvers/url_resolver.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/sol-resolver/src/resolvers/url_resolver.ts b/packages/sol-resolver/src/resolvers/url_resolver.ts new file mode 100644 index 000000000..180b0c9f6 --- /dev/null +++ b/packages/sol-resolver/src/resolvers/url_resolver.ts @@ -0,0 +1,21 @@ +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, + }; + } + return undefined; + } +} |