diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-12-19 21:11:08 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-12-19 22:41:48 +0800 |
commit | 657b698e1eba7fde2322bb81547eba26491c0af4 (patch) | |
tree | 89572e6217df07336f584d56ac0c49e6385e5601 /packages/sol-compiler/src/utils | |
parent | 8ddf925a8feb41e240871fe0d57e0f40b9bb4896 (diff) | |
download | dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar.gz dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar.bz2 dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar.lz dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar.xz dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.tar.zst dexon-sol-tools-657b698e1eba7fde2322bb81547eba26491c0af4.zip |
Add sol-compiler watch mode
Diffstat (limited to 'packages/sol-compiler/src/utils')
-rw-r--r-- | packages/sol-compiler/src/utils/compiler.ts | 7 | ||||
-rw-r--r-- | packages/sol-compiler/src/utils/types.ts | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index 034f72f8d..486d8bedd 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -12,6 +12,7 @@ import { binPaths } from '../solc/bin_paths'; import { constants } from './constants'; import { fsWrapper } from './fs_wrapper'; +import { CompilationError } from './types'; /** * Gets contract data on network or returns if an artifact does not exist. @@ -147,13 +148,13 @@ function printCompilationErrorsAndWarnings(solcErrors: solc.SolcError[]): void { if (!_.isEmpty(errors)) { errors.forEach(error => { const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message); - logUtils.warn(chalk.red(normalizedErrMsg)); + logUtils.log(chalk.red('error'), normalizedErrMsg); }); - throw new Error('Compilation errors encountered'); + throw new CompilationError(errors.length); } else { warnings.forEach(warning => { const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message); - logUtils.warn(chalk.yellow(normalizedWarningMsg)); + logUtils.log(chalk.yellow('warning'), normalizedWarningMsg); }); } } diff --git a/packages/sol-compiler/src/utils/types.ts b/packages/sol-compiler/src/utils/types.ts index b211cfcbc..64328899d 100644 --- a/packages/sol-compiler/src/utils/types.ts +++ b/packages/sol-compiler/src/utils/types.ts @@ -29,3 +29,12 @@ export interface Token { } export type DoneCallback = (err?: Error) => void; + +export class CompilationError extends Error { + public errorsCount: number; + public typeName = 'CompilationError'; + constructor(errorsCount: number) { + super('Compilation errors encountered'); + this.errorsCount = errorsCount; + } +} |