aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-16 23:34:02 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-03-21 22:12:18 +0800
commit8b52793f2fa21bcb23a3c38b6d3773cfc20186fd (patch)
tree82ec9791f2d31d1a60e3ddf019da42b3ee4af2e1 /packages/deployer/src
parent18b9fe525622d9e18491f76136d7697806996a09 (diff)
downloaddexon-sol-tools-8b52793f2fa21bcb23a3c38b6d3773cfc20186fd.tar.gz
dexon-sol-tools-8b52793f2fa21bcb23a3c38b6d3773cfc20186fd.tar.zst
dexon-sol-tools-8b52793f2fa21bcb23a3c38b6d3773cfc20186fd.zip
Add tests for compiler utils
Diffstat (limited to 'packages/deployer/src')
-rw-r--r--packages/deployer/src/globals.d.ts2
-rw-r--r--packages/deployer/src/utils/compiler.ts5
-rw-r--r--packages/deployer/src/utils/fs_wrapper.ts1
3 files changed, 4 insertions, 4 deletions
diff --git a/packages/deployer/src/globals.d.ts b/packages/deployer/src/globals.d.ts
index 3cff8a909..83db346f9 100644
--- a/packages/deployer/src/globals.d.ts
+++ b/packages/deployer/src/globals.d.ts
@@ -1,3 +1,5 @@
+declare module 'dirty-chai';
+
// tslint:disable:completed-docs
declare module 'solc' {
import * as Web3 from 'web3';
diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts
index 3fb35e9ed..1d21d7d31 100644
--- a/packages/deployer/src/utils/compiler.ts
+++ b/packages/deployer/src/utils/compiler.ts
@@ -48,7 +48,7 @@ export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string
* @return Solc compiler version range.
*/
export function parseSolidityVersionRange(source: string): string {
- const SOLIDITY_VERSION_RANGE_REGEX = /pragma solidity (.*);/;
+ const SOLIDITY_VERSION_RANGE_REGEX = /pragma\s+solidity\s+(.*);/;
const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX);
if (_.isNull(solcVersionRangeMatch)) {
throw new Error('Could not find Solidity version range in source');
@@ -104,9 +104,6 @@ export function parseDependencies(source: string): string[] {
*/
export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents {
const fileName = path.basename(importPath);
- if (_.isUndefined(contractSources)) {
- throw new Error('Contract sources not yet initialized');
- }
const source = contractSources[fileName];
if (_.isUndefined(source)) {
throw new Error(`Contract source not found for ${fileName}`);
diff --git a/packages/deployer/src/utils/fs_wrapper.ts b/packages/deployer/src/utils/fs_wrapper.ts
index 34c7caa0e..e02c83f27 100644
--- a/packages/deployer/src/utils/fs_wrapper.ts
+++ b/packages/deployer/src/utils/fs_wrapper.ts
@@ -7,5 +7,6 @@ export const fsWrapper = {
writeFileAsync: promisify<undefined>(fs.writeFile),
mkdirAsync: promisify<undefined>(fs.mkdir),
doesPathExistSync: fs.existsSync,
+ rmdirSync: fs.rmdirSync,
removeFileAsync: promisify<undefined>(fs.unlink),
};