aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-12-19 21:07:20 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-12-19 22:41:48 +0800
commit8ddf925a8feb41e240871fe0d57e0f40b9bb4896 (patch)
tree0467c2cc1a1b9f196c67ac861f093de48550a03e
parentc8eaa63cce99e6666d6d863e8a47007e4cbcbbbb (diff)
downloaddexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar.gz
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar.bz2
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar.lz
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar.xz
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.tar.zst
dexon-sol-tools-8ddf925a8feb41e240871fe0d57e0f40b9bb4896.zip
Add SpyResolver
-rw-r--r--packages/sol-resolver/src/index.ts1
-rw-r--r--packages/sol-resolver/src/resolvers/spy_resolver.ts23
2 files changed, 24 insertions, 0 deletions
diff --git a/packages/sol-resolver/src/index.ts b/packages/sol-resolver/src/index.ts
index a86053259..f55aca070 100644
--- a/packages/sol-resolver/src/index.ts
+++ b/packages/sol-resolver/src/index.ts
@@ -5,5 +5,6 @@ export { NPMResolver } from './resolvers/npm_resolver';
export { FSResolver } from './resolvers/fs_resolver';
export { RelativeFSResolver } from './resolvers/relative_fs_resolver';
export { NameResolver } from './resolvers/name_resolver';
+export { SpyResolver } from './resolvers/spy_resolver';
export { EnumerableResolver } from './resolvers/enumerable_resolver';
export { Resolver } from './resolvers/resolver';
diff --git a/packages/sol-resolver/src/resolvers/spy_resolver.ts b/packages/sol-resolver/src/resolvers/spy_resolver.ts
new file mode 100644
index 000000000..df56c8f9e
--- /dev/null
+++ b/packages/sol-resolver/src/resolvers/spy_resolver.ts
@@ -0,0 +1,23 @@
+import * as fs from 'fs';
+import * as _ from 'lodash';
+import * as path from 'path';
+
+import { ContractSource } from '../types';
+
+import { Resolver } from './resolver';
+
+export class SpyResolver extends Resolver {
+ public resolvedContractSources: ContractSource[] = [];
+ private _resolver: Resolver;
+ constructor(resolver: Resolver) {
+ super();
+ this._resolver = resolver;
+ }
+ public resolveIfExists(importPath: string): ContractSource | undefined {
+ const contractSourceIfExists = this._resolver.resolveIfExists(importPath);
+ if (!_.isUndefined(contractSourceIfExists)) {
+ this.resolvedContractSources.push(contractSourceIfExists);
+ }
+ return contractSourceIfExists;
+ }
+}