-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from cosmos/matt/372-data-dir
Changes to data directory
- Loading branch information
Showing
5 changed files
with
74 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let { join } = require('path') | ||
let { readFileSync } = require('fs') | ||
|
||
// this network gets used if none is specified via the | ||
// COSMOS_NETWORK env var | ||
let DEFAULT_NETWORK = join(__dirname, '../networks/gaia-2') | ||
let networkPath = process.env.COSMOS_NETWORK || DEFAULT_NETWORK | ||
|
||
let genesisText = readFileSync(join(networkPath, 'genesis.json'), 'utf8') | ||
let genesis = JSON.parse(genesisText) | ||
let networkName = genesis.chain_id | ||
|
||
module.exports = { | ||
path: networkPath, | ||
name: networkName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
const { COSMOS_HOME, NODE_ENV } = process.env | ||
|
||
if (COSMOS_HOME) { | ||
module.exports = COSMOS_HOME | ||
} else { | ||
const home = require('user-home') | ||
const { join } = require('path') | ||
const networkName = require('./network.js').name | ||
|
||
const pkg = require('../package.json') | ||
const DEV = NODE_ENV === 'development' | ||
module.exports = join(home, `.${pkg.name}${DEV ? '-dev' : ''}`) | ||
const appName = pkg.name.toLowerCase() | ||
const appDirName = `.${appName}${DEV ? '-dev' : ''}` | ||
|
||
module.exports = join(home, appDirName, networkName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { join } = require('path') | ||
const { homedir } = require('os') | ||
|
||
describe('Root UI Directory', () => { | ||
Object.assign(process.env, { | ||
NODE_ENV: 'development', | ||
COSMOS_NETWORK: 'app/networks/gaia-2', | ||
COSMOS_HOME: '' | ||
}) | ||
|
||
it('should create the correct path', () => { | ||
let root = require('../../../app/src/root.js') | ||
expect(root).toBe(join(homedir(), '.cosmos-dev/gaia-2')) | ||
}) | ||
}) |