aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver/src/resolvers/name_resolver.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-resolver/src/resolvers/name_resolver.ts')
-rw-r--r--packages/sol-resolver/src/resolvers/name_resolver.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/sol-resolver/src/resolvers/name_resolver.ts b/packages/sol-resolver/src/resolvers/name_resolver.ts
index 76bed802e..e489c70a7 100644
--- a/packages/sol-resolver/src/resolvers/name_resolver.ts
+++ b/packages/sol-resolver/src/resolvers/name_resolver.ts
@@ -6,6 +6,8 @@ import { ContractSource } from '../types';
import { EnumerableResolver } from './enumerable_resolver';
+const SOLIDITY_FILE_EXTENSION = '.sol';
+
export class NameResolver extends EnumerableResolver {
private _contractsDir: string;
constructor(contractsDir: string) {
@@ -13,7 +15,6 @@ export class NameResolver extends EnumerableResolver {
this._contractsDir = contractsDir;
}
public resolveIfExists(lookupContractName: string): ContractSource | undefined {
- const SOLIDITY_FILE_EXTENSION = '.sol';
let contractSource: ContractSource | undefined;
const onFile = (filePath: string) => {
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
@@ -32,7 +33,6 @@ export class NameResolver extends EnumerableResolver {
return contractSource;
}
public getAll(): ContractSource[] {
- const SOLIDITY_FILE_EXTENSION = '.sol';
const contractSources: ContractSource[] = [];
const onFile = (filePath: string) => {
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
@@ -59,7 +59,12 @@ export class NameResolver extends EnumerableResolver {
const absoluteEntryPath = path.join(dirPath, fileName);
const isDirectory = fs.lstatSync(absoluteEntryPath).isDirectory();
const entryPath = path.relative(this._contractsDir, absoluteEntryPath);
- const isComplete = isDirectory ? this._traverseContractsDir(absoluteEntryPath, onFile) : onFile(entryPath);
+ let isComplete;
+ if (isDirectory) {
+ isComplete = this._traverseContractsDir(absoluteEntryPath, onFile);
+ } else if (fileName.endsWith(SOLIDITY_FILE_EXTENSION)) {
+ isComplete = onFile(entryPath);
+ }
if (isComplete) {
return isComplete;
}