Skip to content

Commit

Permalink
Added an interface for Cache Directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchPierias committed May 5, 2019
1 parent f22b5b2 commit c005d48
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ const writeFile = promisify(writeFileCallback);
const readFile = promisify(readFileCallback);

/** Root config directory path */
const CONFIG_DIRECTORY = '.lamington';
const CACHE_DIRECTORY = '.lamington';
/** Config file fullpath */
const CONFIG_FILE_PATH = path.join(CONFIG_DIRECTORY, 'config.json');
const CONFIG_FILE_PATH = path.join(CACHE_DIRECTORY, 'config.json');
/** Default encoding */
const ENCODING = 'utf8';
/** Default build output directory */
const DEFAULT_OUTPUT_DIR = '.lamington';
/** Configuration file name */
const CONFIGURATION_FILE_NAME = '.lamingtonrc';

Expand Down Expand Up @@ -80,15 +78,15 @@ export class ConfigManager {
public static async initWithDefaults() {
// Load existing configuration
const userConfig = {
outDir:DEFAULT_OUTPUT_DIR,
outDir:CACHE_DIRECTORY,
keepAlive:false,
exclude:[],
...await ConfigManager.readConfigFromProject()
}
// Check if configuration exists
if (!(await ConfigManager.configExists())) {
// Create the config directory
await mkdirp(CONFIG_DIRECTORY);
await mkdirp(CACHE_DIRECTORY);
// Fetch the latest repository configuration
const defaultConfig: LamingtonConfig = {
cdt: await ConfigManager.getAssetURL('EOSIO', 'eosio.cdt', 'amd64.deb'),
Expand Down Expand Up @@ -164,10 +162,18 @@ export class ConfigManager {
}

/**
* Returns the output build directory or [[DEFAULT_OUTPUT_DIR]]
* Returns the output build directory or [[CACHE_DIRECTORY]]
* @author Mitch Pierias <github.com/MitchPierias>
*/
static get outDir() {
return ConfigManager.config.outDir || DEFAULT_OUTPUT_DIR;
return ConfigManager.config.outDir || CACHE_DIRECTORY;
}

/**
* Returns Lamington's local cache directory name
* @author Mitch Pierias <github.com/MitchPierias>
*/
static get cacheDir() {
return CACHE_DIRECTORY;
}
}

0 comments on commit c005d48

Please sign in to comment.