File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,9 +8,17 @@ var watch = require('metalsmith-watch');
88var collections = require ( 'metalsmith-collections' ) ;
99var excerpts = require ( 'metalsmith-excerpts' ) ;
1010var browserify = require ( 'metalsmith-browserify-alt' ) ;
11+ var msif = require ( 'metalsmith-if' ) ;
1112
1213var preprocess = require ( 'metalsmith-preprocess' ) ;
1314
15+ // look for build flag
16+ var preview = false ;
17+ var args = process . argv . slice ( 2 ) ;
18+ if ( args . length ) {
19+ preview = true ;
20+ }
21+
1422var siteBuild = Metalsmith ( __dirname )
1523 . metadata ( {
1624 site : {
@@ -51,14 +59,21 @@ var siteBuild = Metalsmith(__dirname)
5159 moment : moment ,
5260 partials : "partials"
5361 } ) )
54- . use ( serve ( {
55- port : 8080 ,
56- verbose : true
57- } ) )
58- . use ( watch ( {
59- pattern : '**/*' ,
60- livereload : true
61- } ) )
62+ // livereload and preview server only run if command line argument present
63+ . use ( msif (
64+ preview ,
65+ serve ( {
66+ port : 8080 ,
67+ verbose : true
68+ } )
69+ ) )
70+ . use ( msif (
71+ preview ,
72+ watch ( {
73+ pattern : '**/*' ,
74+ livereload : preview
75+ } )
76+ ) )
6277 . build ( function ( err , files ) {
6378 if ( err ) {
6479 throw err ;
Original file line number Diff line number Diff line change 1212 "metalsmith-browserify-alt" : " ^1.0.1" ,
1313 "metalsmith-collections" : " ^0.7.0" ,
1414 "metalsmith-excerpts" : " ^1.1.0" ,
15+ "metalsmith-if" : " ^0.1.1" ,
1516 "metalsmith-layouts" : " ^1.4.1" ,
1617 "metalsmith-markdown" : " ^0.2.1" ,
1718 "metalsmith-permalinks" : " ^0.1.0" ,
1819 "metalsmith-watch" : " ^1.0.3" ,
1920 "pug" : " ^2.0.0-beta6"
2021 },
2122 "scripts" : {
22- "preview" : " node build.js" ,
23- "deploy" : " node build.js; echo \" done yeah! \" "
23+ "preview" : " node build.js --preview " ,
24+ "deploy" : " node build.js"
2425 }
2526}
You can’t perform that action at this time.
0 commit comments