diff --git a/src/cli/lamington-init.ts b/src/cli/lamington-init.ts index fe8dd5a..bafcdd4 100644 --- a/src/cli/lamington-init.ts +++ b/src/cli/lamington-init.ts @@ -8,12 +8,12 @@ import * as colors from 'colors'; * @author Mitch Pierias */ const run = async () => { + await ProjectManager.initWithDefaults(); - await ProjectManager.initWithDefaults(); - - await ConfigManager.createConfigWhenMissing(); + await ConfigManager.createConfigWhenMissing(); - console.log(colors.white(` + console.log( + colors.white(` . . / ___ , _ , _ \` , __ ___. _/_ __. , __ @@ -22,9 +22,10 @@ const run = async () => { /---/ \`.__/| / ' / / / | \`---| \\__/ \`._.' / | \___/ - `)) + `) + ); }; run().catch(error => { - throw error; + throw error; }); diff --git a/src/cli/utils.ts b/src/cli/utils.ts index 412d432..44ca4f3 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -291,7 +291,10 @@ export const buildAll = async (match?: string[]) => { // Cleanse ignored contracts contracts = onlyMatches(contracts, match) || filterMatches(contracts); // Log the batch building process - console.log(`BUILDING ${contracts.length} SMART CONTRACT${contracts.length>0?'s':''}`, '\n'); + console.log( + `BUILDING ${contracts.length} SMART CONTRACT${contracts.length > 0 ? 's' : ''}`, + '\n' + ); // Build each contract and handle errors for (const contract of contracts) { try { @@ -309,32 +312,30 @@ export const buildAll = async (match?: string[]) => { for (const error of errors) console.error(error.message, '\n', ' -> ', error.error); // Terminate the current process throw new Error( - `${errors.length} contract${errors.length>0?'s':''} failed to compile. Quitting.` + `${errors.length} contract${errors.length > 0 ? 's' : ''} failed to compile. Quitting.` ); } }; -const onlyMatches = (paths:string[], matches:string[] = []) => { +const onlyMatches = (paths: string[], matches: string[] = []) => { return paths.filter(filePath => { return matches.reduce((result, str) => { - const pattern = new RegExp(str,'gi'); - if (result || pattern.test(filePath)) - result = true; + const pattern = new RegExp(str, 'gi'); + if (result || pattern.test(filePath)) result = true; return result; - }, false) + }, false); }); -} +}; -const filterMatches = (paths:string[]) => { +const filterMatches = (paths: string[]) => { return paths.filter(filePath => { return !ConfigManager.exclude.reduce((result, match) => { - const pattern = new RegExp(match,'gi'); - if (result || pattern.test(filePath)) - result = true; + const pattern = new RegExp(match, 'gi'); + if (result || pattern.test(filePath)) result = true; return result; }, false); }); -} +}; /** * Resolves the path to file identifier. diff --git a/src/configManager.ts b/src/configManager.ts index b58f21d..f6a80ea 100644 --- a/src/configManager.ts +++ b/src/configManager.ts @@ -101,10 +101,13 @@ export class ConfigManager { // Save cached configuration await writeFile( CONFIG_FILE_PATH, - JSON.stringify({ + JSON.stringify( + { ...existingConfig, ...userConfig, - }, null, 4 + }, + null, + 4 ), ENCODING ); @@ -113,7 +116,7 @@ export class ConfigManager { } public static async createConfigWhenMissing() { - const atPath = path.join(process.cwd(),'.lamingtonrc'); + const atPath = path.join(process.cwd(), '.lamingtonrc'); if (await ConfigManager.configExists(atPath)) return; ConfigManager.initWithDefaults(); await writeFile(atPath, JSON.stringify(ConfigManager.config, null, 4), ENCODING); @@ -127,7 +130,7 @@ export class ConfigManager { * @param atPath Optional file path for lookup * @returns Config exists determiner */ - public static async configExists(atPath:string = CONFIG_FILE_PATH) { + public static async configExists(atPath: string = CONFIG_FILE_PATH) { // Should filter out any trailing filename and concatonate // the default filename return await exists(atPath);