pages:reset error gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead - zurb-foundation-6

As delivered, Foundation for sites 6 CLI generates an error when the gulp task pages:reset is called. This happens anytime you edit files down in src/layouts or src/partials.
Apparently, gulp.run() has been deprecated.
Using run-sequence repairs the problem.
Around line 80 of gulpfile.js:
gulp.task('pages:reset', function(cb) {
panini.refresh();
//gulp.run('pages');
sequence('pages',cb);
browser.reload();
});

Thanks for this. I had to do it a little differently in order to ensure the change and copy happens before the browser reload.
gulp.task('pages:reset', function(cb) {
panini.refresh();
// gulp.run('pages', cb);
sequence('pages', function(){
cb();
browser.reload();
});
});

Related

Display gulp --tasks from within task

I want to dump out a message within the default gulp task to tell the user to select a task, but then list out the tasks below this message the same way which gulp --tasks does.
Can't seem to find anything on Google which will do this without additional plugins, which I want to avoid, if there a way?
exports.default = (cb) => {
log(chalk.bgRed('Please run a task, a list has been provided below.'));
// dump out tasks here
cb();
};
If you just want to log the list of the gulp tasks, you can use child_process to execute gulp --task
const exec = require('child_process').execSync
exec('gulp --tasks', { stdio: 'inherit' })

node-cron task works even when server is restarted with node-cron task commented in my nodejs server

I m using package for task sechdule in my nodejs/parseserver open source
https://www.npmjs.com/package/node-cron
but even i comment the job and restarted servert ...job seems running.....can some one guide me here??
var counter=0;
Parse.Cloud.define("test", function(request, response) {
response.success(counter+1);
});
//var cron = require('node-cron');
//var task=cron.schedule('*/1 * * * *', function(){
/* Parse.Cloud.run('test',{}, {
success: function(results) {
console.log('test');
response.success(results);
},
error: function(error) {
response.error("Some error.");
}
}); */
//console.log('job creared loop');
//});
It sounds like the file where the cronjob is, is not loading with the changes. But some information is missing from your question I think.
Which server are you referring to & what server:
1. Are you just running the node fafa.js program again?
2. Are you working with Forever or PM2? If PM2 you need to
sudo pm2 restart [name of file]
Are you completely restarting the whole server??? (AWS etc)
Perhaps a simple
console.log("see if cron job runs")
within the code will show you what is going on. Obviously if the console.log does not appear the old code is still running.
I think if the above is not the case we would need more information.

gulp.watch task is throwing an error: (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR

This recently started happening in my gulp.watch task. It was working fine as of two weeks ago.
When I run $ gulp
when it gets to the watch task, it throws the following:
(FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
events.js:85
throw er; // Unhandled 'error' event
^
Error: watch EMFILE
at exports._errnoException (util.js:746:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1157:26)
Per a few suggestions, I have updated node.js, with no luck.
There was also the suggestion that I was trying to watch too many files, so I changed the watch dir to a single file. Still throws the error.
Ive updated gulp to 3.9 globally and locally, along with my dependencies. I even rolled gulp back to an older version on both to see if that worked. No luck.
What could be throwing this on a gulp.watch task?
Here is my gulpfile task:
// Watch
gulp.task('watch', function() {
// Listen on port 35729
server.listen(35729, function (err) {
if (err) {
return console.log(err)
};
// Watch .scss files
gulp.watch('assets/styles/*.scss', ['styles']);
});
});
From the code you've posted, you've invoked gulp.watch but with no instruction as to what should happen when a file changes?
Normally a watch task would trigger the running of another task upon a file change. One would assume that watching changes in scss files should trigger scss compilation.
gulp.watch('assets/styles/style.scss', ['scss:compile']);
// where 'scss:compile' is another defined task for scss compilation.
Hope that helps you out and might give you some different output :)

Gulp clean gives inconsistent results

I have the following basic Gulp tasks:
gulp.task('clean', function(){
return del('./build/public/js');
});
gulp.task('doSomething', ['clean'], function(){
console.log(fs.existsSync('./build/public/js'));
return gulp.src(..... // Do some stuff here
});
According to this, the directory ./build/public/js is first deleted by the clean task. This runs synchronously since I am using return in that task.
Next the first thing my doSomething task does is prints out whether or not the ./build/public/js directory exists or not. This should be false EVERY TIME.
But sometimes I get true. I have no idea why. Here is my output when it is true:
[13:57:13] Using gulpfile /vhosts/website/gulpfile.js
[13:57:13] Starting 'clean'...
[13:57:13] Finished 'clean' after 30 ms
[13:57:13] Starting 'doSomething'...
true
[13:57:13] 'doSomething' errored after 196 ms
[13:57:13] Error: EEXIST, mkdir '/vhosts/website/build/public/js'
What is going on here? Why are my results inconsistent? clean finishes before doSomething starts, so the directory should definitely be completely deleted at that point. Why would it ever return true, saying the directory still exists?
You need to help gulp understand when the task is finished:
gulp.task('clean', function(cb) {
del('./build/public/js', cb);
});
https://github.com/gulpjs/gulp/blob/master/docs/API.md#deps
Note: Are your tasks running before the dependencies are complete? Make sure your dependency tasks are correctly using the async run hints: take in a callback or return a promise or event stream.

Unable to get connect-livereload to work with express server in gulp task

I am working off of Yeoman's gulp-webapp generator. I have modified my gulp serve task to use my Express server, rather than the default connect server it ships with. My issue is with Livereload functionality. I am trying to simply port the connect-livereload to work with my Express server rather than having to install new dependencies. It's to my understanding that most connect middleware should work fine with Express, so I am assuming connect livereload is compatible with Express 4.
Here are the contents of the relevant tasks in my gulpfile:
gulp.task('express', function() {
var serveStatic = require('serve-static');
var app = require('./server/app');
app.use(require('connect-livereload')({port: 35729}))
.use(serveStatic('.tmp'));
app.listen(3000);
});
gulp.task('watch', ['express'], function () {
$.livereload.listen();
// watch for changes
gulp.watch([
'app/*.ejs',
'.tmp/styles/**/*.css',
'app/scripts/**/*.js',
'app/images/**/*'
]).on('change', $.livereload.changed);
gulp.watch('app/styles/**/*.css', ['styles']);
gulp.watch('bower.json', ['wiredep']);
});
gulp.task('styles', function () {
return gulp.src('app/styles/main.css')
.pipe($.autoprefixer({browsers: ['last 1 version']}))
.pipe(gulp.dest('.tmp/styles'));
});
gulp.task('serve', ['express', 'watch'], function () {
require('opn')('http://localhost:3000');
});
With this simple setup, when I run gulp serve in my cmd everything spins up fine and I can accept requests at http://localhost:3000.
Now if I go and change the body's background color from #fafafa to #f00 in main.css and hit save, my gulp output will respond with main.css was reloaded, as seen in the bottom of this screenshot.
However, my webpage does not update. The background color is still light-grey instead of red.
Is there perhaps a conflict between my express server config and the way gulp handles its files? Is my Express server forcing the use of app/styles/main.css rather than the use of .tmp/styles/main.css? Shouldn't the livereload script handle the injection of the new temporary file?
Thanks for any help.
EDIT:
I was able to move forward a bit by adding livereload.js to the script block of my index file, like so:
<script src="http://localhost:35729/livereload.js"></script>
I am now able to get live changes pushed to the client. Why was this file not getting injected before? How can I ensure this is getting used programatically as opposed to pasting it into my files?
I was able to get past this issue by removing the app.use(require('connect-livereload')({port: 35729})) from my gulpfile, along with a couple of other lines, and having that instantiate in my Express server's app.js file.
My gulpfile's express task now looks like this:
gulp.task('express', function() {
var app = require('./server/app');
app.listen(3000);
});
I added in the connect-livereload just above where I specify my static directory in Express:
if (app.get('env') === 'development') {
app.use(require('connect-livereload')());
}
app.use(express.static(path.join(__dirname, '../app')));
Once I started using this setup, I was getting the livereload.js script injected into my document, and client-side changes are now auto-refreshed just how I wanted.
Hope this helps someone!

Resources