Skip to content

Commit 26b1109

Browse files
committed
Merge pull request #4 from vesln/rc
Read params from local runtime config if any
2 parents 6b20b13 + a774a5d commit 26b1109

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

.notesrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
src

bin/notes

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env node
22

3+
/**
4+
* Core dependencies.
5+
*/
6+
var fs = require('fs');
7+
var path = require('path');
8+
39
/**
410
* Notes.
511
*
@@ -14,10 +20,30 @@ var Notes = require('../lib/notes');
1420
*/
1521
var argv = process.argv.slice(2, process.argv.length);
1622

17-
if (0 === argv.length) {
18-
return new Notes(process.cwd()).annotate();
23+
/**
24+
* Current working directory.
25+
*
26+
* @type {String}
27+
*/
28+
var cwd = process.cwd();
29+
30+
/**
31+
* Runtime configurations path.
32+
*
33+
* @type {String}
34+
*/
35+
var rc = path.join(cwd, '.notesrc');
36+
37+
if (0 !== argv.length) {
38+
return argv.forEach(function(arg) {
39+
new Notes(arg).annotate();
40+
});
41+
}
42+
43+
if (!fs.existsSync(rc)) {
44+
return new Notes(cwd).annotate();
1945
}
2046

21-
argv.forEach(function(arg) {
22-
new Notes(arg).annotate();
47+
fs.readFileSync(rc, 'utf8').trim().split(/\s+/).forEach(function(directory) {
48+
new Notes(directory).annotate();
2349
});

0 commit comments

Comments
 (0)