aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-resolver
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-08-14 05:17:05 +0800
committerGitHub <noreply@github.com>2018-08-14 05:17:05 +0800
commit25a8554be1550e00fba023fd56a3a6e181888e81 (patch)
treeba2a4a40fdc0f59983e314dfce600c5e1006ae7d /packages/sol-resolver
parentcd76c129da0026527a03707e54d90a63325a9fea (diff)
downloaddexon-0x-contracts-25a8554be1550e00fba023fd56a3a6e181888e81.tar.gz
dexon-0x-contracts-25a8554be1550e00fba023fd56a3a6e181888e81.tar.zst
dexon-0x-contracts-25a8554be1550e00fba023fd56a3a6e181888e81.zip
fix(sol-compiler, sol-resolver): Bug where sol-resolver tried to read a directory (#961)
fix(sol-compiler, sol-resolver): Fix bug where sol-resolver tried to read a directory
Diffstat (limited to 'packages/sol-resolver')
-rw-r--r--packages/sol-resolver/CHANGELOG.json4
-rw-r--r--packages/sol-resolver/src/resolvers/npm_resolver.ts2
2 files changed, 5 insertions, 1 deletions
diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json
index abce53d09..dd9cb3f5d 100644
--- a/packages/sol-resolver/CHANGELOG.json
+++ b/packages/sol-resolver/CHANGELOG.json
@@ -5,6 +5,10 @@
{
"note": "Fix a bug where RelativeFSResolver would crash when trying to read a directory",
"pr": 909
+ },
+ {
+ "note": "Fix a bug where NpmResolver would crash when trying to read a directory",
+ "pr": 961
}
]
},
diff --git a/packages/sol-resolver/src/resolvers/npm_resolver.ts b/packages/sol-resolver/src/resolvers/npm_resolver.ts
index 9f8617145..a2df0dcad 100644
--- a/packages/sol-resolver/src/resolvers/npm_resolver.ts
+++ b/packages/sol-resolver/src/resolvers/npm_resolver.ts
@@ -19,7 +19,7 @@ export class NPMResolver extends Resolver {
const ROOT_PATH = '/';
while (currentPath !== ROOT_PATH) {
const lookupPath = path.join(currentPath, 'node_modules', packageName, pathWithinPackage);
- if (fs.existsSync(lookupPath)) {
+ if (fs.existsSync(lookupPath) && fs.lstatSync(lookupPath).isFile()) {
const fileContent = fs.readFileSync(lookupPath).toString();
return {
source: fileContent,