grunt-nginx
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -9,4 +9,4 @@ 'use strict'; | ||
options: { | ||
config: 'conf_file', | ||
prefix: 'prefix_path' | ||
config: '/path/to/nginx/nginx.conf', | ||
prefix: '../../nginx/' | ||
test: false, | ||
@@ -13,0 +13,0 @@ globals: ['pid /var/run/nginx.pid', 'worker_processes 2'] |
{ | ||
"name": "grunt-nginx", | ||
"description": "Grunt task for Nginx to start, stop and restart a server.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/alexcurtis/grunt-nginx", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -34,18 +34,23 @@ grunt-nginx | ||
#### config ```string``` | ||
#### config ```string``` - required | ||
Specify which configuration file Nginx should use instead of the default. | ||
#### prefix ```string``` | ||
#### prefix ```string``` - optional | ||
Sets the prefix path (default: /usr/local/nginx/). Any references in the config file will be relative to this path. | ||
#### globals ```string``` | ||
#### globals ```string``` - optional | ||
Sets global directives. Further Information can be found [here](http://wiki.nginx.org/NginxMainModule). | ||
#### test ```string``` | ||
#### test ```string``` - optional | ||
Don't run, just test the configuration file. Nginx checks configuration for correct syntax and then try to open files referred in configuration. | ||
### Paths | ||
grunt-nginx supports both absolute and relative paths. Like most grunt plugins, relative paths are with respect to the `Gruntfile.js` gruntfile. | ||
### Example | ||
@@ -56,4 +61,4 @@ | ||
options: { | ||
config: '/home/alex/nginx.conf', | ||
prefix: '/home/alex/nginx' | ||
config: '/path/to/nginx.conf', | ||
prefix: './relative/path/nginx' | ||
globals: ['pid /var/run/nginx.pid', 'worker_processes 2'] | ||
@@ -60,0 +65,0 @@ } |
'use strict'; | ||
var path = require('path'); | ||
module.exports = function(grunt) { | ||
@@ -14,7 +16,14 @@ | ||
var fullpath = function(p, type, required){ | ||
var fp = path.resolve(p); | ||
if(grunt.file.exists(fp) || !required) { return fp; } | ||
var error = ' (' + type + ' path): is required, but invalid.' | ||
throw fp + error; | ||
}; | ||
var argument = function(options){ | ||
var args = []; | ||
if(options.signal) { args.push('-s'); args.push(options.signal); } | ||
if(options.config) { args.push('-c'); args.push(options.config); } | ||
if(options.prefix) { args.push('-p'); args.push(options.prefix); } | ||
if(options.config) { args.push('-c'); args.push(fullpath(options.config, 'config', true)); } | ||
if(options.prefix) { args.push('-p'); args.push(fullpath(options.prefix, 'prefix')); } | ||
var globals = options.globals; | ||
@@ -21,0 +30,0 @@ if(globals){ |
6746
94
68