diff options
author | F. Eugene Aumson <gene@aumson.org> | 2018-09-21 22:56:17 +0800 |
---|---|---|
committer | F. Eugene Aumson <gene@aumson.org> | 2018-09-22 22:14:49 +0800 |
commit | 3e5d427d4e873080f2a369db7f844cbadd610fcb (patch) | |
tree | 214cd2cad9ce278aeac61f25a31f6ccccb5637cb /packages/sol-compiler | |
parent | 301e491952707cdad8929cb918209a3792201a7d (diff) | |
download | dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar.gz dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar.bz2 dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar.lz dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar.xz dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.tar.zst dexon-sol-tools-3e5d427d4e873080f2a369db7f844cbadd610fcb.zip |
feat: add sol-doc command-line interface
modified sol-compiler to output progress/warning/error/etc messages to
stderr rather than stdout, so that sol-doc can put its output (and
nothing else) to stdout.
for posterity, added sol-doc cli usage as npm scripts to package.json.
Diffstat (limited to 'packages/sol-compiler')
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 14 | ||||
-rw-r--r-- | packages/sol-compiler/src/utils/compiler.ts | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 3b0bd90f9..a29367485 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -94,7 +94,7 @@ export class Compiler { if (await fsWrapper.doesFileExistAsync(compilerBinFilename)) { solcjs = (await fsWrapper.readFileAsync(compilerBinFilename)).toString(); } else { - logUtils.log(`Downloading ${fullSolcVersion}...`); + logUtils.warn(`Downloading ${fullSolcVersion}...`); const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`; const response = await fetchAsync(url); const SUCCESS_STATUS = 200; @@ -181,7 +181,9 @@ export class Compiler { path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION), ); } else { - contractNamesToCompile = this._specifiedContracts; + contractNamesToCompile = this._specifiedContracts.map(specifiedContract => + path.basename(specifiedContract, constants.SOLIDITY_FILE_EXTENSION), + ); } return contractNamesToCompile; } @@ -236,7 +238,7 @@ export class Compiler { const solcVersions = _.keys(versionToInputs); for (const solcVersion of solcVersions) { const input = versionToInputs[solcVersion]; - logUtils.log( + logUtils.warn( `Compiling ${input.contractsToCompile.length} contracts (${ input.contractsToCompile }) with Solidity v${solcVersion}...`, @@ -329,7 +331,7 @@ export class Compiler { const artifactString = utils.stringifyWithFormatting(newArtifact); const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; await fsWrapper.writeFileAsync(currentArtifactPath, artifactString); - logUtils.log(`${contractName} artifact saved!`); + logUtils.warn(`${contractName} artifact saved!`); } private _compile(solcInstance: solc.SolcInstance, standardInput: solc.StandardInput): solc.StandardOutput { const compiled: solc.StandardOutput = JSON.parse( @@ -345,13 +347,13 @@ export class Compiler { if (!_.isEmpty(errors)) { errors.forEach(error => { const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message); - logUtils.log(chalk.red(normalizedErrMsg)); + logUtils.warn(chalk.red(normalizedErrMsg)); }); throw new Error('Compilation errors encountered'); } else { warnings.forEach(warning => { const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message); - logUtils.log(chalk.yellow(normalizedWarningMsg)); + logUtils.warn(chalk.yellow(normalizedWarningMsg)); }); } } diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index c918ed1f3..c153beb0f 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -26,7 +26,7 @@ export async function getContractArtifactIfExistsAsync( contractArtifact = JSON.parse(contractArtifactString); return contractArtifact; } catch (err) { - logUtils.log(`Artifact for ${contractName} does not exist`); + logUtils.warn(`Artifact for ${contractName} does not exist`); return undefined; } } @@ -37,7 +37,7 @@ export async function getContractArtifactIfExistsAsync( */ export async function createDirIfDoesNotExistAsync(dirPath: string): Promise<void> { if (!fsWrapper.doesPathExistSync(dirPath)) { - logUtils.log(`Creating directory at ${dirPath}...`); + logUtils.warn(`Creating directory at ${dirPath}...`); await fsWrapper.mkdirpAsync(dirPath); } } |