Only look at *.sol files in NameResolver
This commit is contained in:
@@ -6,6 +6,8 @@ import { ContractSource } from '../types';
|
|||||||
|
|
||||||
import { EnumerableResolver } from './enumerable_resolver';
|
import { EnumerableResolver } from './enumerable_resolver';
|
||||||
|
|
||||||
|
const SOLIDITY_FILE_EXTENSION = '.sol';
|
||||||
|
|
||||||
export class NameResolver extends EnumerableResolver {
|
export class NameResolver extends EnumerableResolver {
|
||||||
private _contractsDir: string;
|
private _contractsDir: string;
|
||||||
constructor(contractsDir: string) {
|
constructor(contractsDir: string) {
|
||||||
@@ -13,7 +15,6 @@ export class NameResolver extends EnumerableResolver {
|
|||||||
this._contractsDir = contractsDir;
|
this._contractsDir = contractsDir;
|
||||||
}
|
}
|
||||||
public resolveIfExists(lookupContractName: string): ContractSource | undefined {
|
public resolveIfExists(lookupContractName: string): ContractSource | undefined {
|
||||||
const SOLIDITY_FILE_EXTENSION = '.sol';
|
|
||||||
let contractSource: ContractSource | undefined;
|
let contractSource: ContractSource | undefined;
|
||||||
const onFile = (filePath: string) => {
|
const onFile = (filePath: string) => {
|
||||||
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
|
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
|
||||||
@@ -32,7 +33,6 @@ export class NameResolver extends EnumerableResolver {
|
|||||||
return contractSource;
|
return contractSource;
|
||||||
}
|
}
|
||||||
public getAll(): ContractSource[] {
|
public getAll(): ContractSource[] {
|
||||||
const SOLIDITY_FILE_EXTENSION = '.sol';
|
|
||||||
const contractSources: ContractSource[] = [];
|
const contractSources: ContractSource[] = [];
|
||||||
const onFile = (filePath: string) => {
|
const onFile = (filePath: string) => {
|
||||||
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
|
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
|
||||||
@@ -56,6 +56,9 @@ export class NameResolver extends EnumerableResolver {
|
|||||||
throw new Error(`No directory found at ${dirPath}`);
|
throw new Error(`No directory found at ${dirPath}`);
|
||||||
}
|
}
|
||||||
for (const fileName of dirContents) {
|
for (const fileName of dirContents) {
|
||||||
|
if (!fileName.endsWith(SOLIDITY_FILE_EXTENSION)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const absoluteEntryPath = path.join(dirPath, fileName);
|
const absoluteEntryPath = path.join(dirPath, fileName);
|
||||||
const isDirectory = fs.lstatSync(absoluteEntryPath).isDirectory();
|
const isDirectory = fs.lstatSync(absoluteEntryPath).isDirectory();
|
||||||
const entryPath = path.relative(this._contractsDir, absoluteEntryPath);
|
const entryPath = path.relative(this._contractsDir, absoluteEntryPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user