Skip to content

Commit e8edabb

Browse files
author
MaxGenash
committed
refactor(/bin/stencil-start): rearrange some variables
1 parent b520daa commit e8edabb

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

bin/stencil-start

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
#!/usr/bin/env node
22

3+
require('colors');
34
const Bs = require('browser-sync').create();
4-
const Cycles = require('../lib/cycles');
55
const recursiveRead = require('recursive-readdir');
66
const Async = require('async');
7-
const templateAssembler = require('../lib/template-assembler');
7+
const Wreck = require('wreck');
88
const Fs = require('fs');
9-
const JspmAssembler = require('../lib/jspm-assembler');
109
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');
1115
const Pkg = require('../package.json');
1216
const Program = require('commander');
1317
const Server = require('../server');
1418
const ThemeConfig = require('../lib/theme-config');
1519
const buildConfig = require('../lib/build-config');
16-
const Url = require('url');
17-
const Wreck = require('wreck');
1820
const jsonLint = require('../lib/json-lint');
1921
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');
2527

2628
Program
2729
.version(Pkg.version)
@@ -32,6 +34,11 @@ Program
3234
.option('-n, --no-cache', 'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.')
3335
.parse(process.argv);
3436

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
3542

3643
if (!versionCheck()) {
3744
return;
@@ -211,12 +218,6 @@ async function startServer() {
211218
watchIgnored = buildConfig.watchOptions.ignored;
212219
}
213220

214-
const tunnel = typeof Program.tunnel === 'undefined'
215-
? false
216-
: Program.tunnel === true
217-
? true
218-
: Program.tunnel;
219-
220221
Bs.init({
221222
open: !!Program.open,
222223
port: browserSyncPort,

0 commit comments

Comments
 (0)