@@ -10,25 +10,49 @@ const Mustache = require('mustache');
1010var scrawl = require ( './www/scrawl' ) ;
1111var Twitter = require ( 'twitter' ) ;
1212var wp = require ( 'wordpress' ) ;
13+ const yaml = require ( 'js-yaml' ) ;
1314
1415program
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+
2643if ( ! 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
3357const dstDir = path . resolve ( path . join ( program . directory ) ) ;
3458const logFile = path . resolve ( dstDir , 'irc.log' ) ;
@@ -37,11 +61,11 @@ const indexFile = path.resolve(dstDir, 'index.html');
3761const minutesDir = path . join ( dstDir , '/..' ) ;
3862
3963var htmlHeader = fs . readFileSync (
40- __dirname + '/ www/_partials/header.html', { encoding : 'utf8' } ) ;
64+ path . join ( base_dir , ' www/_partials/header.html') , { encoding : 'utf8' } ) ;
4165var htmlFooter = fs . readFileSync (
42- __dirname + '/ www/_partials/footer.html', { encoding : 'utf8' } ) ;
66+ path . join ( base_dir , ' www/_partials/footer.html') , { encoding : 'utf8' } ) ;
4367var peopleJson = fs . readFileSync (
44- __dirname + '/ www/people.json', { encoding : 'utf8' } ) ;
68+ path . join ( base_dir , ' www/people.json') , { encoding : 'utf8' } ) ;
4569var gLogData = '' ;
4670var haveAudio = false ;
4771var 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 ;
0 commit comments