Skip to content

Commit

Permalink
Randomize development build server port
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Ganni committed Jan 4, 2017
1 parent 9b75f2e commit 7a3be5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -26,13 +26,13 @@ You'll need NodeJS, use this command to access the main branch and install the d
cd vnmsim && npm install
```

You'll need Gulp and Express to compile it. For debugging mode (it will start a web server on `localhost:3000` and you'll find the compiled simulator source in `build`) just run:
You'll need Gulp and Express to compile it. For debugging mode (it will start a web server on `localhost`, the port will be displayed as soon as the compilation ends and you'll find the compiled simulator source in `build`) just run:

```
gulp
```

To compile it for production (it will take a little more time to uglify the source code, it won't start the server and the output will be located in `dist`):
To compile it for production (it won't start the server and the output will be located in `dist`):

```
gulp --production
Expand Down
4 changes: 2 additions & 2 deletions app.js
Expand Up @@ -4,5 +4,5 @@ var express = require('express'),

app.use(express.static(__dirname + '/build'));

app.listen(3000);
console.log('Listening on port 3000');
var listener = app.listen(0);
console.log('Express server listening on port ' + listener.address().port);
34 changes: 15 additions & 19 deletions gulpfile.js
Expand Up @@ -94,19 +94,6 @@ gulp.task('samplesZip', () => {
.pipe(gulp.dest(dest));
});

// server and watchers
gulp.task('server', function () {
server.run(['app.js']);

gulp.watch('src/templates/**/*', ['templates']);
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('src/locale/*.json', ['scripts']);
gulp.watch('src/img/**/*', ['styles']);
gulp.watch('src/sass/**/*.sass', ['styles']);
gulp.watch('samples/*.json', ['samplesList', 'samplesFolder', 'samplesZip']);
gulp.watch('build/**/*', server.notify);
});

// tasks to be executed during build
var tasks = [
'styles',
Expand All @@ -115,14 +102,23 @@ var tasks = [
'samplesFolder',
'samplesZip',
'templates',
'fonts',
'server'
'fonts'
];
// remove server task in production mode
if (argv.production) tasks.pop();

// default task
gulp.task('default', tasks, function() {
// end message
console.log('Build ended');

// in development start server and watchers
if (!argv.production) {
server.run(['app.js']);

gulp.watch('src/templates/**/*', ['templates']);
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('src/locale/*.json', ['scripts']);
gulp.watch('src/img/**/*', ['styles']);
gulp.watch('src/sass/**/*.sass', ['styles']);
gulp.watch('samples/*.json', ['samplesList', 'samplesFolder', 'samplesZip']);
gulp.watch('build/**/*', server.notify);

}
});

0 comments on commit 7a3be5d

Please sign in to comment.