aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/utils.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-19 08:28:38 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-21 03:19:30 +0800
commit613a78bcf62c10d27d7def8f0ff54efadc2faefb (patch)
tree05e897cec5bb2d26c3a77d4a44597966a54f0dee /packages/sol-cov/src/utils.ts
parentf5decb1d7e8de9a198f1cf1b258a043181ce26d5 (diff)
downloaddexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.gz
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.bz2
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.lz
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.xz
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.tar.zst
dexon-sol-tools-613a78bcf62c10d27d7def8f0ff54efadc2faefb.zip
Include source code snippets in revert stack traces
Diffstat (limited to 'packages/sol-cov/src/utils.ts')
-rw-r--r--packages/sol-cov/src/utils.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/sol-cov/src/utils.ts b/packages/sol-cov/src/utils.ts
index 4f16a1cda..d31696636 100644
--- a/packages/sol-cov/src/utils.ts
+++ b/packages/sol-cov/src/utils.ts
@@ -66,4 +66,10 @@ export const utils = {
}
return structLogs;
},
+ getRange(sourceCode: string, range: SingleFileSourceRange): string {
+ const lines = sourceCode.split('\n').slice(range.start.line - 1, range.end.line);
+ lines[lines.length - 1] = lines[lines.length - 1].slice(0, range.end.column);
+ lines[0] = lines[0].slice(range.start.column);
+ return lines.join('\n');
+ },
};