1
1
#!/usr/bin/env node
2
2
3
+ require ( 'colors' ) ;
3
4
const Bs = require ( 'browser-sync' ) . create ( ) ;
4
- const Cycles = require ( '../lib/cycles' ) ;
5
5
const recursiveRead = require ( 'recursive-readdir' ) ;
6
6
const Async = require ( 'async' ) ;
7
- const templateAssembler = require ( '../lib/template-assembler ' ) ;
7
+ const Wreck = require ( 'wreck ' ) ;
8
8
const Fs = require ( 'fs' ) ;
9
- const JspmAssembler = require ( '../lib/jspm-assembler' ) ;
10
9
const Path = require ( 'path' ) ;
10
+ const Url = require ( 'url' ) ;
11
+
12
+ const Cycles = require ( '../lib/cycles' ) ;
13
+ const templateAssembler = require ( '../lib/template-assembler' ) ;
14
+ const JspmAssembler = require ( '../lib/jspm-assembler' ) ;
11
15
const Pkg = require ( '../package.json' ) ;
12
16
const Program = require ( 'commander' ) ;
13
17
const Server = require ( '../server' ) ;
14
18
const ThemeConfig = require ( '../lib/theme-config' ) ;
15
19
const buildConfig = require ( '../lib/build-config' ) ;
16
- const Url = require ( 'url' ) ;
17
- const Wreck = require ( 'wreck' ) ;
18
20
const jsonLint = require ( '../lib/json-lint' ) ;
19
21
const versionCheck = require ( '../lib/version-check' ) ;
20
- let themePath = process . cwd ( ) ;
21
- let templatePath = Path . join ( themePath , 'templates' ) ;
22
- let dotStencilFilePath = Path . join ( themePath , '.stencil ' ) ;
23
- let themeConfigPath = Path . join ( themePath , 'config.json ' ) ;
24
- require ( 'colors ') ;
22
+
23
+ const themePath = process . cwd ( ) ;
24
+ const templatePath = Path . join ( themePath , 'templates ' ) ;
25
+ const dotStencilFilePath = Path . join ( themePath , '.stencil ' ) ;
26
+ const themeConfigPath = Path . join ( themePath , 'config.json ') ;
25
27
26
28
Program
27
29
. version ( Pkg . version )
@@ -32,6 +34,11 @@ Program
32
34
. option ( '-n, --no-cache' , 'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.' )
33
35
. parse ( process . argv ) ;
34
36
37
+ // tunnel value should be true/false or a string with name
38
+ // https://browsersync.io/docs/options#option-tunnel
39
+ const tunnel = typeof Program . tunnel === 'string'
40
+ ? Program . tunnel
41
+ : Boolean ( Program . tunnel ) // convert undefined/true -> false/true
35
42
36
43
if ( ! versionCheck ( ) ) {
37
44
return ;
@@ -211,12 +218,6 @@ async function startServer() {
211
218
watchIgnored = buildConfig . watchOptions . ignored ;
212
219
}
213
220
214
- const tunnel = typeof Program . tunnel === 'undefined'
215
- ? false
216
- : Program . tunnel === true
217
- ? true
218
- : Program . tunnel ;
219
-
220
221
Bs . init ( {
221
222
open : ! ! Program . open ,
222
223
port : browserSyncPort ,
0 commit comments