Comparing version 0.0.2 to 0.0.3
@@ -8,3 +8,3 @@ var apacheconf = require('./') | ||
config.apacheconf.forEach(function(vh) { | ||
config.VirtualHost.forEach(function(vh) { | ||
if (vh.ServerName) vh.ServerName.forEach(function(d) { | ||
@@ -11,0 +11,0 @@ domains.push(d) |
64
index.js
@@ -6,2 +6,3 @@ var inherits = require('util').inherits | ||
, fs = require('fs') | ||
, path = require('path') | ||
, glob = require('glob') | ||
@@ -17,6 +18,13 @@ | ||
module.exports = function(filename, cb) { | ||
module.exports = function(filename, options, cb) { | ||
if (arguments.length == 2) { | ||
cb = options | ||
options = {} | ||
} | ||
var stream = fs.createReadStream(filename) | ||
, parser = new Parser() | ||
parser.serverRoot = options.serverRoot || '/usr/local/apache' | ||
parser.file = filename | ||
@@ -32,2 +40,6 @@ parser._stream = es.pause() | ||
stream.on('error', function(err) { | ||
parser.emit('error', err) | ||
}) | ||
if (cb) { | ||
@@ -47,7 +59,2 @@ parser.on('error', cb) | ||
stream.pipe(es.split('\n')).pipe(parser._stream).pipe(parser, { end: false }) | ||
stream.on('error', function(err) { | ||
parser.emit('error', err) | ||
}) | ||
} | ||
@@ -142,10 +149,34 @@ | ||
glob(value, function onfiles(err, files) { | ||
if (err) return self.emit('error', err) | ||
glob(path.resolve(this._getProp('serverRoot'), value), function(err, files) { | ||
self._include(files.shift(), function(err) { | ||
if (err || files.length) return onfiles(err, files) | ||
self.resume() | ||
}) | ||
var current | ||
function next(err) { | ||
if (err) { | ||
if (err.code == 'EISDIR') { | ||
fs.readdir(current, function(err, _files) { | ||
if (err) return next(err) | ||
files = _files.map(function(file) { | ||
return path.resolve(current, file) | ||
}).concat(files) | ||
next() | ||
}) | ||
} else { | ||
self.emit('error', err) | ||
} | ||
return | ||
} | ||
if (!files.length) return self.resume() | ||
current = files.shift() | ||
self._include(current, next) | ||
} | ||
next(err) | ||
}) | ||
@@ -219,3 +250,3 @@ | ||
self._stream.on('end', function() { | ||
function cleanup(err) { | ||
self._stream = origStream | ||
@@ -225,5 +256,8 @@ self.file = origFile | ||
cb() | ||
}) | ||
cb(err) | ||
} | ||
self._stream.on('end', cleanup) | ||
stream.on('error', cleanup) | ||
} |
{ | ||
"name": "apacheconf", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Apacheconf is an apache config file parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6496
202