Skip to content

Commit

Permalink
Removed directory management from startEos and implemented user def…
Browse files Browse the repository at this point in the history
…ined build dirs in `build`
  • Loading branch information
MitchPierias committed May 5, 2019
1 parent 255a60a commit 0088872
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,12 @@ export const eosIsReady = async () => {
};

/**
* Starts a new EOSIO docker image
* Pulls the EOSIO docker image if it doesn't exist and starts
* a new EOSIO docker container
* @author Kevin Brown <github.com/thekevinbrown>
* @author Mitch Pierias <github.com/MitchPierias>
*/
export const startEos = async () => {
// Create build result cache directories
await mkdirp(path.join(WORKING_DIRECTORY, '.lamington', 'compiled_contracts'));
await mkdirp(path.join(WORKING_DIRECTORY, '.lamington', 'data'));
// Ensure an EOSIO build image exists
if (!(await imageExists())) {
console.log('--------------------------------------------------------------');
Expand Down Expand Up @@ -312,11 +310,19 @@ export const pathToIdentifier = (filePath: string) =>
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(contractPath);
await compileContract(fullPath);
// Generate Typescript definitions for contract
await generateTypes(pathToIdentifier(contractPath));
spinner.create(`Generating type definitions`);
try {
await generateTypes(pathToIdentifier(contractPath));
spinner.end(`Generated type definitions`);
} catch (error) {
spinner.fail(`Failed to generate type definitions`);
console.log(` --> ${error.message}`);
}
};

/**
Expand All @@ -338,11 +344,13 @@ export const compileContract = async (contractPath: string) => {
'eosio',
'bin',
'project',
contractPath
'contracts',
basename,
basename+'.cpp'
)}" "${path.dirname(contractPath)}" "${basename}"`
).catch(err => {
spinner.fail("Failed to compile");
throw new Error(`Failed to compile ${basename}`)
console.log(` --> ${err.message}`);
});
// Notify build task completed
spinner.end(`Compiled contract`);
Expand Down

0 comments on commit 0088872

Please sign in to comment.