mirror of https://github.com/snachodog/mybuddy.git
Add the ability to set the development server IP address from gulp
This commit is contained in:
parent
c51e755c0f
commit
4a81e2c5a9
|
@ -160,6 +160,8 @@ in the [`babybuddy/management/commands`](babybuddy/management/commands) folder.
|
||||||
#### `gulp`
|
#### `gulp`
|
||||||
|
|
||||||
Executes the `build` and `watch` commands and runs Django's development server.
|
Executes the `build` and `watch` commands and runs Django's development server.
|
||||||
|
This command also accepts the special parameter `--ip` for setting the
|
||||||
|
development server IP address. See [`gulp runserver`](#runserver) for details.
|
||||||
|
|
||||||
#### `build`
|
#### `build`
|
||||||
|
|
||||||
|
@ -240,8 +242,12 @@ fake data.
|
||||||
|
|
||||||
#### `runserver`
|
#### `runserver`
|
||||||
|
|
||||||
Executes Django's `runserver` management task. Gulp also passes along
|
Executes Django's `runserver` management task. Gulp passes non-overlapping
|
||||||
non-overlapping arguments for this command.
|
arguments for this command.
|
||||||
|
|
||||||
|
A special parameter, `--ip`, is also available to set the IP for the server.
|
||||||
|
E.g execute `gulp runserver --ip 0.0.0.0:8000` to make the server available to
|
||||||
|
other devices on your local network.
|
||||||
|
|
||||||
#### `scripts`
|
#### `scripts`
|
||||||
|
|
||||||
|
|
25
gulpfile.js
25
gulpfile.js
|
@ -216,7 +216,30 @@ gulp.task('clean', clean);
|
||||||
|
|
||||||
gulp.task('runserver', function(cb) {
|
gulp.task('runserver', function(cb) {
|
||||||
var command = ['run', 'python', 'manage.py', 'runserver'];
|
var command = ['run', 'python', 'manage.py', 'runserver'];
|
||||||
command = command.concat(process.argv.splice(3));
|
|
||||||
|
/**
|
||||||
|
* Process any parameters. Any arguments found here will be removed from
|
||||||
|
* the parameters list so other parameters continue to be passed to the
|
||||||
|
* command.
|
||||||
|
**/
|
||||||
|
var parameters = process.argv.splice(2);
|
||||||
|
for (var i = 0; i < parameters.length; i++) {
|
||||||
|
/* May be included because this is the default gulp command. */
|
||||||
|
if (parameters[i] === 'runserver') {
|
||||||
|
delete parameters[i];
|
||||||
|
}
|
||||||
|
/* "--ip" parameter to set the server IP address. */
|
||||||
|
else if (parameters[i] === '--ip') {
|
||||||
|
command.push(parameters[i+1]);
|
||||||
|
delete parameters[i];
|
||||||
|
delete parameters[i+1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add parameters to command, removing empty values. */
|
||||||
|
command = command.concat(parameters.filter(String));
|
||||||
|
|
||||||
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
|
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue