Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
fixes #136: gulp watch --no-open
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Grupp committed Feb 25, 2015
1 parent 2e0f2fb commit 1a0a728
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -82,11 +82,11 @@ yo m

## Gulp tasks
#### gulp watch
Prepares everything for development. Get ready to start coding!
Prepares everything for development and opens your default browser. Get ready to start coding!
```sh
gulp watch
```
Livereloads your application when changing/adding/deleting files to immediately reflect the changes you made. Restart this task when you're adding modules and bower components! This is because gulp will only notify the creation of the new folders, not the individual files inside.
Livereloads your application when changing/adding/deleting files to immediately reflect the changes you make. If you don't want this task to open your browser just add the `--no-open` option and navigate to `http://localhost:9000` yourself.


#### gulp watch-build
Expand Down Expand Up @@ -181,7 +181,6 @@ gulp --cordova 'run ios' # won't work on windows
'<newModuleName>'
]);
```
3. restart `gulp watch`
3. navigate to `http://127.0.0.1:9000/#/<module-name-in-snake-case>` in your browser.
4. **Done!** - see your new module in action!

Expand Down
41 changes: 21 additions & 20 deletions app/templates/gulp_tasks/watching.js
Expand Up @@ -4,6 +4,7 @@
// gulp
var gulp = require('gulp');
var paths = gulp.paths;
var options = gulp.options;
// plugins
var $ = require('gulp-load-plugins')();
// modules
Expand All @@ -14,16 +15,24 @@ var serveStatic = require('serve-static');
var connectLiveReload = require('connect-livereload');

var createConnectServer = function (paths) {
var app = connect()
return function () {
var app = connect()
.use(connectLiveReload({port: 35729}));
for (var key in paths) {
app.use(serveStatic(paths[key]));
for (var key in paths) {
app.use(serveStatic(paths[key]));
}
http.createServer(app)
.listen(9000)
.on('listening', function () {
console.log('Started connect web server on http://localhost:9000');
});
};
};

var open = function () {
if (options.open !== false) {
opn('http://localhost:9000');
}
http.createServer(app)
.listen(9000)
.on('listening', function () {
console.log('Started connect web server on http://localhost:9000');
});
};

// WATCH
Expand Down Expand Up @@ -52,12 +61,8 @@ gulp.task('watch', ['serve', 'linting'], function () {
// watch for changes in environment files
gulp.watch('app/main/constants/env-*.json', ['environment']);
});
gulp.task('serve', ['connect', 'inject-all'], function () {
opn('http://localhost:9000');
});
gulp.task('connect', function () {
createConnectServer(['app', '.tmp']);
});
gulp.task('serve', ['connect', 'inject-all'], open);
gulp.task('connect', createConnectServer(['app', '.tmp']));

// WATCH-BUILD
gulp.task('watch-build', ['serve-build'], function () {
Expand All @@ -67,9 +72,5 @@ gulp.task('watch-build', ['serve-build'], function () {
$.livereload.reload();
});
});
gulp.task('serve-build', ['connect-build', 'build'], function () {
opn('http://localhost:9000');
});
gulp.task('connect-build', function () {
createConnectServer(paths.dist);
});
gulp.task('serve-build', ['connect-build', 'build'], open);
gulp.task('connect-build', createConnectServer(paths.dist));

0 comments on commit 1a0a728

Please sign in to comment.