1
- 'use strict' ;
2
1
3
- var gulp = require ( 'gulp' ) ;
4
- var browserSync = require ( 'browser-sync' ) . create ( ) ;
5
- var fs = require ( 'fs' ) ;
6
- var yaml = require ( 'js-yaml' ) ;
7
- var debug = require ( 'debug' ) ( 'slate-tools:deploy' ) ;
8
2
9
- var config = require ( './includes/config.js' ) ;
10
- var messages = require ( './includes/messages.js' ) ;
3
+ const gulp = require ( 'gulp' ) ;
4
+ const browserSync = require ( 'browser-sync' ) . create ( ) ;
5
+ const fs = require ( 'fs' ) ;
6
+ const yaml = require ( 'js-yaml' ) ;
7
+ const debug = require ( 'debug' ) ( 'slate-tools:deploy' ) ;
8
+
9
+ const config = require ( './includes/config.js' ) ;
10
+ const messages = require ( './includes/messages.js' ) ;
11
11
12
12
/**
13
13
* Starts a [browserSync]{@link https://www.browsersync.io/} session proxying your
@@ -17,24 +17,24 @@ var messages = require('./includes/messages.js');
17
17
* @memberof slate-cli.tasks.deploy
18
18
* @static
19
19
*/
20
- gulp . task ( 'deploy:sync-init' , function ( ) {
20
+ gulp . task ( 'deploy:sync-init' , ( ) => {
21
21
if ( browserSync . active ) {
22
22
browserSync . exit ( ) ;
23
23
} else {
24
24
fs . writeFileSync ( config . deployLog , '' ) ; // eslint-disable-line no-sync
25
25
}
26
26
27
- var file = fs . readFileSync ( config . tkConfig , 'utf8' ) ; // eslint-disable-line no-sync
28
- var tkConfig = yaml . safeLoad ( file ) ;
29
- var queryStringComponents = [ ] ;
30
- var environment = config . environment . split ( / \s * , \s * | \s + / ) [ 0 ] ;
27
+ const file = fs . readFileSync ( config . tkConfig , 'utf8' ) ; // eslint-disable-line no-sync
28
+ const tkConfig = yaml . safeLoad ( file ) ;
29
+ const queryStringComponents = [ ] ;
30
+ const environment = config . environment . split ( / \s * , \s * | \s + / ) [ 0 ] ;
31
31
32
- var envObj = tkConfig [ environment ] ;
33
- var proxyTarget = ' https://' + envObj . store ;
32
+ const envObj = tkConfig [ environment ] ;
33
+ let proxyTarget = ` https://${ envObj . store } ` ;
34
34
35
35
// break theme preview cache by always setting a preview parameter
36
- var previewParam = envObj . theme_id === 'live' ? '' : envObj . theme_id ;
37
- proxyTarget += ' ?preview_theme_id=' + previewParam ;
36
+ const previewParam = envObj . theme_id === 'live' ? '' : envObj . theme_id ;
37
+ proxyTarget += ` ?preview_theme_id=${ previewParam } ` ;
38
38
39
39
debug ( proxyTarget ) ;
40
40
@@ -48,11 +48,19 @@ gulp.task('deploy:sync-init', function () {
48
48
proxy : {
49
49
target : proxyTarget ,
50
50
middleware : function middleware ( req , res , next ) {
51
- var prefix = req . url . indexOf ( '?' ) > - 1 ? '&' : '?' ;
51
+ const prefix = req . url . indexOf ( '?' ) > - 1 ? '&' : '?' ;
52
52
req . url += prefix + queryStringComponents . join ( '&' ) ;
53
53
next ( ) ;
54
- }
55
- }
54
+ } ,
55
+ } ,
56
+ snippetOptions : {
57
+ rule : {
58
+ match : / < \/ b o d y > / i,
59
+ fn : function ( snippet , match ) {
60
+ return snippet + match ;
61
+ } ,
62
+ } ,
63
+ } ,
56
64
} ) ;
57
65
} ) ;
58
66
@@ -64,10 +72,10 @@ gulp.task('deploy:sync-init', function () {
64
72
* @memberof slate-cli.tasks.watch
65
73
* @static
66
74
*/
67
- gulp . task ( 'deploy:sync-reload' , [ 'deploy:sync-init' ] , function ( ) {
75
+ gulp . task ( 'deploy:sync-reload' , [ 'deploy:sync-init' ] , ( ) => {
68
76
gulp . watch ( config . tkConfig , [ 'deploy:sync-init' ] ) ;
69
- gulp . watch ( config . deployLog , function ( ) {
77
+ gulp . watch ( config . deployLog , ( ) => {
70
78
messages . logTransferDone ( ) ;
71
79
browserSync . reload ( ) ;
72
80
} ) ;
73
- } ) ;
81
+ } ) ;
0 commit comments