Skip to content

Commit

Permalink
Merge pull request #40 from pipocadigital/resolve-watch
Browse files Browse the repository at this point in the history
Resolve watch task
  • Loading branch information
alisonmonteiro authored Apr 26, 2018
2 parents 64424df + 896d3b4 commit cb124e8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 44 deletions.
63 changes: 32 additions & 31 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
const gulp = require('gulp');
const gulpSync = require('gulp-sync')(gulp);
const requireDir = require('require-dir');
const requireTasksDir = require('require-dir');
const packageJson = require('./package.json');

const baseConfig = {
const config = {
packageJson,
port: 3000,
phpPort: 3838,
localhost: 'localhost',
packageJson: packageJson,
compressed: true
localhost: 'localhost'
};

const wpThemePath = 'wordpress/wp-content/themes/' + packageJson.name;
const paths = {
const developmentPaths = {
pages: 'src/**/*.php',
fonts: 'src/fonts/**/*.*',
images: 'src/images/**/*.*',
styles: 'src/css/**/*.sass',
scripts: 'src/js/**/*.js'
};

const themes = 'wordpress/wp-content/themes/';
const theTheme = themes + packageJson.name;
const paths = Object.assign({
basePath: 'wordpress/',
pluginsWp: 'plugins/**/*.*',
styleWp: 'src/style.css',
configWp: 'wp-config.php',
pagesDest: wpThemePath,
fontsDest: wpThemePath + '/fonts',
imagesDest: wpThemePath + '/images',
stylesDest: wpThemePath + '/css',
scriptsDest: wpThemePath + '/js',
themesWp: 'wordpress/wp-content/themes/'
};
pluginsWp: 'plugins/**/*.*',

const devPaths = {
pages: 'src/**/*.php',
scripts: 'src/js/**/*.js',
styles: 'src/css/**/*.sass',
images: 'src/images/**/*.*',
fonts: 'src/fonts/**/*.*'
};
themesWp: themes,
pagesDest: theTheme,
fontsDest: `${theTheme}/fonts`,
imagesDest: `${theTheme}/images`,
stylesDest: `${theTheme}/css`,
scriptsDest: `${theTheme}/js`
}, developmentPaths);

gulp.paths = Object.assign(devPaths, paths);
gulp.config = baseConfig;
gulp.paths = paths;
gulp.config = config;

// Gulp tasks
requireDir('tasks');
requireTasksDir('tasks');

gulp.task('wp', gulpSync.sync(['wp-install']));
gulp.task('default', gulpSync.sync(['build', 'watch', 'connect-sync']));
gulp.task('build', gulpSync.sync(['clean', 'styles', 'scripts', 'pages', 'images', 'fonts', 'libs']));

gulp.task('watch', () => {
gulp.watch(gulp.paths.styles, ['styles']);
gulp.watch(gulp.paths.scripts, ['scripts']);
gulp.watch(gulp.paths.pages, ['pages']);
gulp.watch(gulp.paths.images, ['images']);
gulp.watch(gulp.paths.fonts, ['fonts']);
const paths = Object.keys(developmentPaths);

paths.map(path => {
// Combine each development path with a task
return gulp.watch(gulp.paths[path], [path]);
});
});
8 changes: 0 additions & 8 deletions tasks/browser-sync.js

This file was deleted.

5 changes: 4 additions & 1 deletion tasks/connect-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ gulp.task('connect-sync', function() {

connect.server(serverConfig, () => browserSync({
proxy: proxy,
port: gulp.config.port
port: gulp.config.port,
snippetOptions: {
ignorePaths: ['wp-admin/**']
}
}));
});
5 changes: 2 additions & 3 deletions tasks/wp-install.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const gulp = require('gulp');
const request = require('request');
const zlib = require('zlib');
const fs = require('fs');
const AdmZip = require('adm-zip');
const admZip = require('adm-zip');
const readlineSync = require('readline-sync');
const helper = require('./helpers');

Expand Down Expand Up @@ -43,7 +42,7 @@ gulp.task('wp-install', function() {

helper.log('Unzipping WordPress...', 'success');

const zip = new AdmZip(outputZip);
const zip = new admZip(outputZip);
zip.extractAllTo('./');
fs.unlink(outputZip);

Expand Down
1 change: 0 additions & 1 deletion tasks/wp-pre-build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const del = require('del');

gulp.task('wp-pre-build', function() {
Expand Down

0 comments on commit cb124e8

Please sign in to comment.