Skip to content

Commit

Permalink
Readded initWithDefaults to load existing or user defined config
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchPierias committed May 19, 2019
1 parent bca6519 commit 6c4ffbd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
13 changes: 3 additions & 10 deletions src/cli/lamington-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,16 @@ import { ConfigManager } from '../configManager';
* @author Mitch Pierias <github.com/MitchPierias>
*/
const run = async () => {
// Capture CLI defined contract identifiers
const contract = process.argv[2];

if (!(await ConfigManager.configExists())) {
console.log('Project has not yet been initialised.');
console.log('Please run lamington init before running this command.');

process.exit(1);
}

// Initialize Lamington configuration
await ConfigManager.initWithDefaults()
// Start the EOSIO container image if it's not running.
if (!(await eosIsReady())) {
await startEos();
}

// Build all smart contracts
await buildAll([contract]);

// And stop it if we don't have keepAlive set.
if (!ConfigManager.keepAlive) {
await stopContainer();
Expand Down
9 changes: 2 additions & 7 deletions src/cli/lamington-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ import { ConfigManager } from '../configManager';
* @author Kevin Brown <github.com/thekevinbrown>
*/
const run = async () => {
if (!(await ConfigManager.configExists())) {
console.log('Project has not yet been initialised.');
console.log('Please run lamington init before running this command.');

process.exit(1);
}


await ConfigManager.initWithDefaults();
// Stop running instances for fresh test environment
if (await eosIsReady()) {
await stopContainer();
Expand Down
8 changes: 2 additions & 6 deletions src/cli/lamington-stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import { ConfigManager } from '../configManager';
* @author Kevin Brown <github.com/thekevinbrown>
*/
const run = async () => {
if (!(await ConfigManager.configExists())) {
console.log('Project has not yet been initialised.');
console.log('Please run lamington init before running this command.');

process.exit(1);
}

await ConfigManager.initWithDefaults();

if (!(await eosIsReady())) {
console.log(`Can't stop the container as EOS is already not running.`);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/lamington-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ConfigManager } from '../configManager';
*/
const run = async () => {
// Initialize the configuration
await ConfigManager.loadConfigFromDisk();
await ConfigManager.initWithDefaults()

// Stop running instances for fresh test environment
if (await eosIsReady()) {
Expand Down
23 changes: 20 additions & 3 deletions src/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ export class ConfigManager {
/** @hidden EOSIO and EOSIO.CDT configuration settings */
private static config: LamingtonConfig;

/**
* Initialize application configuration using the user
* defined configurations and defaults
* @author Kevin Brown <github.com/thekevinbrown>
* @author Mitch Pierias <github.com/MitchPierias>
*/
public static async initWithDefaults() {

if (!(await ConfigManager.configExists())) {
console.log('Project has not yet been initialized.');
console.log('Please run lamington init before running this command.');

process.exit(1);
}

await ConfigManager.loadConfigFromDisk();
}

/**
* Downloads the organization's latest repository release image and
* returns the assets matching the specified filter
Expand Down Expand Up @@ -153,15 +171,14 @@ export class ConfigManager {
}

/**
* Returns the container keep alive setting or false
* Returns the container's debug log output setting
* @author Kevin Brown <github.com/thekevinbrown>
*/
static get debugTransactions() {
return true;
return (
(ConfigManager.config && ConfigManager.config.debugTransactions) ||
DEFAULT_CONFIG.debugTransactions
);
)
}

/**
Expand Down

0 comments on commit 6c4ffbd

Please sign in to comment.