Skip to content

Commit

Permalink
store in subfolder called /data and ensure that folder exists. adds to
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Mar 22, 2015
1 parent 573752b commit ba0e22d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ app.on('ready', function() {
})

ipc.on('open-dir', function openDir (ev) {
shell.showItemInFolder(conf.exec.cwd)
shell.showItemInFolder(path.join(conf.exec.cwd, 'config.json'))
})

ipc.on('get-all', function getAll (ev, data) {
Expand All @@ -78,14 +78,15 @@ app.on('ready', function() {
})

function loadConfig() {
var dir = app.getPath('userData')
var dir = path.join(app.getPath('userData'), 'data')
var configFile = dir + '/config.json'
var conf, data

try {
data = fs.readFileSync(configFile)
} catch (e) {
if (e.code === 'ENOENT') {
mkdir(dir)
fs.writeFileSync(configFile, fs.readFileSync(__dirname + '/config.json'))
return loadConfig()
} else {
Expand Down

0 comments on commit ba0e22d

Please sign in to comment.