Completed
Push — master ( 32309e...c5e908 )
by Ankit
02:57
created

gulpfile.js (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
var gulp = require('gulp'),
2
    gutil = require('gulp-util'),
3
    uglify = require('gulp-uglify'),
4
    concat = require('gulp-concat');
5
    connect = require('gulp-connect-php'),
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
The variable connect seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.connect.
Loading history...
6
    browserSync = require('browser-sync');
0 ignored issues
show
The variable browserSync seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.browserSync.
Loading history...
7
8
var jsSources = ['js/*.js'],
9
    phpSources = ['*.php'];
10
11
12
13
14
15
gulp.task('log', function() {
16
  gutil.log('== My First Task ==')
17
});
18
19
// gulp.task('copy', function() {
20
//   gulp.src('index.html')
21
//   .pipe(gulp.dest(outputDir))
22
// });
23
24
// gulp.task('sass', function() {
25
//   gulp.src(sassSources)
26
//   .pipe(sass({style: 'expanded'}))
27
//     .on('error', gutil.log)
28
//   .pipe(gulp.dest('assets'))
29
//   .pipe(connect.reload())
30
// });
31
32
// gulp.task('coffee', function() {
33
//   gulp.src(coffeeSources)
34
//   .pipe(coffee({bare: true})
35
//     .on('error', gutil.log))
36
//   .pipe(gulp.dest('scripts'))
37
// });
38
39
// gulp.task('js', function() {
40
//   gulp.src(jsSources)
41
//   .pipe(uglify())
42
//   .pipe(concat('script.js'))
43
//   .pipe(gulp.dest('js'))
44
//   .pipe(connect.reload())
45
// });
46
47
48
49
// gulp.task('watch', function() {
50
51
//   livereload.listen();
52
//   // gulp.watch('*.php').on('change', livereload.reload);
53
54
//     gulp.watch('*.php').on('change', function(file) {
55
//           gutil.log("Changed" + file.path);
56
//           livereload.changed(file.path);
57
//       });
58
59
// });
60
61
62
// gulp.task('connect', function() {
63
//   connectPHP.server({
64
//     hostname: '127.0.0.1',
65
//     bin: 'C:/xampp/php/php.exe',
66
//     ini: 'C:/xampp/php/php.ini',
67
//     port: 3000,
68
//     base: '.',
69
//     livereload: true
70
//   // }, function () {
71
//   //         browserSync.init({
72
//   //           proxy: "localhost:3000"
73
//   //   });
74
//   });
75
// });
76
77
78
79
80
gulp.task('connect', function() {
81
  connect.server({
82
    hostname: '127.0.0.1',
83
    port: 3000,
84
    base: '.'
85
  }, function() {
86
    browserSync({
87
      proxy: '127.0.0.1:3000',
88
      port: 8888
89
  });
90
  });
91
});
92
93
gulp.task('watch', function() {
94
  gulp.watch(['**/*.php']).on('change', browserSync.reload);
95
});
96
97
98
//task that fires up browserSync proxy after connect server has started
99
// gulp.task('browser-sync',['connect'], function() {
100
101
// });
102
103
104
//default task that runs task browser-sync ones and then watches php files to change. If they change browserSync is reloaded
105
// gulp.task('default', ['browser-sync'], function () {
106
//   gulp.watch(['*.php'], browserSync.reload);
107
// });
108
109
gulp.task('default', ['connect', 'watch']);