Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
Moved output directory contatenation from `buid` and into the `compileContract` function
  • Loading branch information
MitchPierias committed May 5, 2019
1 parent ca7e030 commit f627d1d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,14 @@ export const pathToIdentifier = (filePath: string) => filePath.substr(0, filePat
* Builds contract resources for contract at path
* @author Kevin Brown <github.com/thekevinbrown>
* @author Mitch Pierias <github.com/MitchPierias>
* @param contractPath Fullpath to C++ contract file
* @param contractPath Local path to C++ contract file
*/
export const build = async (contractPath: string) => {
// Get the base filename from path and log status
const basename = path.basename(contractPath, '.cpp');
const fullPath = path.join('./', ConfigManager.outDir, contractPath);
console.log(basename);
// Compile contract at path
await compileContract(fullPath);
await compileContract(contractPath);
// Generate Typescript definitions for contract
spinner.create(`Generating type definitions`);
try {
Expand All @@ -355,6 +354,7 @@ export const compileContract = async (contractPath: string) => {
spinner.create(`Compiling contract`);
// Get the base filename from path and log status
const basename = path.basename(contractPath, '.cpp');
const fullPath = path.join(ConfigManager.outDir, path.dirname(contractPath));
// Pull docker images
await docker.command(
// Arg 1 is filename, arg 2 is contract name.
Expand All @@ -363,13 +363,12 @@ export const compileContract = async (contractPath: string) => {
'eosio',
'bin',
'project',
'contracts',
basename,
basename+'.cpp'
)}" "${path.dirname(contractPath)}" "${basename}"`
contractPath
)}" "${fullPath}" "${basename}"`
).catch(err => {
spinner.fail("Failed to compile");
console.log(` --> ${err.message}`);
console.log(` --> ${err}`);
throw err;
});
// Notify build task completed
spinner.end(`Compiled contract`);
Expand Down

0 comments on commit f627d1d

Please sign in to comment.