2015-12-10 23:52:20 +08:00
|
|
|
import fs from 'fs-plus'
|
|
|
|
import path from 'path'
|
|
|
|
import CSON from 'season'
|
|
|
|
|
|
|
|
var root = path.resolve(path.dirname(__dirname))
|
|
|
|
|
|
|
|
const DEFAULT_CONFIG_DIR = path.join(root, "fixtures", "default_test_config")
|
|
|
|
export const CONFIG_DIR_PATH = path.join(root, ".integration-test-config")
|
|
|
|
export const FAKE_DATA_PATH = path.join(root, "fixtures", "test_account_data")
|
|
|
|
|
|
|
|
export function setupDefaultConfig() {
|
|
|
|
if (fs.existsSync(CONFIG_DIR_PATH)) fs.removeSync(CONFIG_DIR_PATH);
|
|
|
|
fs.copySync(DEFAULT_CONFIG_DIR, CONFIG_DIR_PATH)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearConfig() {
|
|
|
|
if (fs.existsSync(CONFIG_DIR_PATH)) fs.removeSync(CONFIG_DIR_PATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function currentConfig(){
|
|
|
|
version = JSON.parse(fs.readFileSync(path.join(root, '..', 'package.json'))).version;
|
2016-04-27 04:17:29 +08:00
|
|
|
config = CSON.readFileSync(path.join(DEFAULT_CONFIG_DIR, 'config.json'))["*"]
|
2015-12-10 23:52:20 +08:00
|
|
|
id = config.updateIdentity
|
|
|
|
email = config.nylas.accounts[0].email_address
|
|
|
|
|
|
|
|
return {id, email, version}
|
|
|
|
}
|