Skip to content

Commit 2fe6c39

Browse files
committed
Make dataPath available to both loadData and save.
1 parent 2ddfb50 commit 2fe6c39

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/bang.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
this.loadData();
1212
}
1313

14+
Bang.prototype.dataPath = process.env.HOME + "/.bang";
15+
1416
Bang.prototype.loadData = function() {
15-
var dataPath;
16-
dataPath = process.env.HOME + "/.bang";
17-
return this.data = path.existsSync(dataPath) ? JSON.parse(fs.readFileSync(dataPath)) : {};
17+
return this.data = path.existsSync(this.dataPath) ? JSON.parse(fs.readFileSync(this.dataPath)) : {};
1818
};
1919

2020
Bang.prototype.save = function() {

src/bang.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ module.exports = class Bang
77
constructor: ->
88
@loadData()
99

10+
# The file where data is persisted to disk.
11+
dataPath: process.env.HOME + "/.bang"
12+
1013
# Initializes Bang's data store.
1114
loadData: ->
12-
dataPath = process.env.HOME + "/.bang"
13-
14-
@data = if path.existsSync dataPath
15-
JSON.parse fs.readFileSync dataPath
15+
@data = if path.existsSync @dataPath
16+
JSON.parse fs.readFileSync @dataPath
1617
else
1718
{}
1819

0 commit comments

Comments
 (0)