diff options
Diffstat (limited to 'packages/sol-resolver')
-rw-r--r-- | packages/sol-resolver/CHANGELOG.json | 13 | ||||
-rw-r--r-- | packages/sol-resolver/src/resolvers/fs_resolver.ts | 2 | ||||
-rw-r--r-- | packages/sol-resolver/src/resolvers/name_resolver.ts | 11 |
3 files changed, 22 insertions, 4 deletions
diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index 44de3825e..895bd2104 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,5 +1,18 @@ [ { + "version": "0.0.5", + "changes": [ + { + "note": "Fix a bug in FsResolver where it tries to read directories as files", + "pr": 589 + }, + { + "note": "Fix a bug in NameResolver where it is not ignoring .sol files", + "pr": 589 + } + ] + }, + { "timestamp": 1527009133, "version": "0.0.5", "changes": [ diff --git a/packages/sol-resolver/src/resolvers/fs_resolver.ts b/packages/sol-resolver/src/resolvers/fs_resolver.ts index 4f05fba88..63fc3448e 100644 --- a/packages/sol-resolver/src/resolvers/fs_resolver.ts +++ b/packages/sol-resolver/src/resolvers/fs_resolver.ts @@ -7,7 +7,7 @@ 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)) { + if (fs.existsSync(importPath) && fs.lstatSync(importPath).isFile()) { const fileContent = fs.readFileSync(importPath).toString(); return { source: fileContent, 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; } |