Skip to content

Commit b3d8948

Browse files
committed
Begin setup of YAML config
Where all the Mustaches and other configs will live
1 parent fb80e2c commit b3d8948

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

index.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,49 @@ const Mustache = require('mustache');
1010
var scrawl = require('./www/scrawl');
1111
var Twitter = require('twitter');
1212
var wp = require('wordpress');
13+
const yaml = require('js-yaml');
1314

1415
program
1516
.version('0.4.0')
17+
// the setup switches
18+
.option('-c, --config <file>', 'The YAML configuration file.')
1619
.option('-d, --directory <directory>', 'The directory to process.')
20+
// the do something switches
1721
.option('-m, --html', 'If set, write the minutes to an index.html file')
1822
.option('-w, --wordpress', 'If set, publish the minutes to the blog')
1923
.option('-e, --email', 'If set, publish the minutes to the mailing list')
2024
.option('-t, --twitter', 'If set, publish the minutes to Twitter')
2125
.option('-g, --google', 'If set, publish the minutes to G+')
2226
.option('-i, --index', 'Build meeting index')
27+
// the tweak the cli switch
2328
.option('-q, --quiet', 'Don\'t print status information to the console')
2429
.parse(process.argv);
2530

31+
var base_dir = __dirname;
32+
var config = {};
33+
if (program.config) {
34+
try {
35+
config = yaml.safeLoad(fs.readFileSync(program.config, 'utf8'));
36+
// paths in the config file are relative to the config files location
37+
base_dir = path.resolve(path.dirname(program.config));
38+
} catch (e) {
39+
console.error(e.message);
40+
}
41+
}
42+
2643
if(!program.directory) {
2744
console.error('Error: You must specify a directory to process');
2845
program.outputHelp();
2946
process.exit(1);
3047
}
3148

49+
if (!program.html && !program.wordpress && !program.email && !program.twitter
50+
&& !program.google && !program.index) {
51+
console.error('Error: Nothing to do...');
52+
program.outputHelp();
53+
process.exit(1);
54+
}
55+
3256
// setup global variables
3357
const dstDir = path.resolve(path.join(program.directory));
3458
const logFile = path.resolve(dstDir, 'irc.log');
@@ -37,11 +61,11 @@ const indexFile = path.resolve(dstDir, 'index.html');
3761
const minutesDir = path.join(dstDir, '/..');
3862

3963
var htmlHeader = fs.readFileSync(
40-
__dirname + '/www/_partials/header.html', {encoding: 'utf8'});
64+
path.join(base_dir, 'www/_partials/header.html'), {encoding: 'utf8'});
4165
var htmlFooter = fs.readFileSync(
42-
__dirname + '/www/_partials/footer.html', {encoding: 'utf8'});
66+
path.join(base_dir, 'www/_partials/footer.html'), {encoding: 'utf8'});
4367
var peopleJson = fs.readFileSync(
44-
__dirname + '/www/people.json', {encoding: 'utf8'});
68+
path.join(base_dir, 'www/people.json'), {encoding: 'utf8'});
4569
var gLogData = '';
4670
var haveAudio = false;
4771
var gDate = path.basename(dstDir);
@@ -277,7 +301,7 @@ async.waterfall([ function(callback) {
277301
}
278302

279303
const summaryIntro = fs.readFileSync(
280-
__dirname + '/www/_partials/summary-intro.html', {encoding: 'utf8'});
304+
path.join(base_dir, 'www/_partials/summary-intro.html'), {encoding: 'utf8'});
281305

282306
// write out summary file
283307
var summaryHtml = htmlHeader + '<div id="info">' + summaryIntro;

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"commander": "~1.0.0",
2323
"emailjs": "~2.1.0",
2424
"html-entities": "~1.0.10",
25+
"js-yaml": "^3.12.0",
2526
"mailparser": "~0.2.26",
2627
"mime": "^2.3.1",
2728
"moment": "~2.19.3",

0 commit comments

Comments
 (0)