Comparing version 0.0.12 to 0.0.13
36
index.js
'use strict'; | ||
var q = require('q'); | ||
var shell = require('shelljs/global'); | ||
var async = require('async'); | ||
var linter = require('./lib/linter'); | ||
var cache = require('./lib/cache'); | ||
var processPatterns = require('./lib/process'); | ||
var stdout = false; | ||
var linter = function (file, cb) { | ||
cache.has(file, function(err, isCached, hash) { | ||
if (err) return cb(err); | ||
if (isCached && stdout) { | ||
return cache.get(hash, function (err, cached) { | ||
process.stdout.write(cached.contents); | ||
cb(); | ||
}); | ||
} | ||
if (isCached && ! stdout) { | ||
return cb(); | ||
} | ||
exec('php -l '+file, {silent: ! stdout}, function (code, output) { | ||
var err = (code === 0) ? null : output.trim(); | ||
if (err) return cb(err); | ||
cache.put(hash, output, cb); | ||
}); | ||
}); | ||
}; | ||
module.exports = function (patterns, options) { | ||
@@ -16,7 +44,5 @@ var deferred = q.defer(); | ||
var limit = options.limit ? options.limit : 10; | ||
var stdout = options.stdout ? options.stdout : false; | ||
stdout = options.stdout ? options.stdout : false; | ||
async.eachLimit(result, limit, function (file, cb) { | ||
linter(file, {stdout: stdout}, cb); | ||
}, function (err) { | ||
async.eachLimit(result, limit, linter, function (err) { | ||
if (err) return deferred.reject(new Error(err.trim())); | ||
@@ -23,0 +49,0 @@ |
{ | ||
"name": "phplint", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "wrapper for php -l", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,3 +23,3 @@ 'use strict'; | ||
it('should call the then method', function (cb) { | ||
var lint = phplint('test/pass.php'); | ||
var lint = phplint('test/pass.php', {stdout: true}); | ||
lint.then(function (msg) { | ||
@@ -26,0 +26,0 @@ cb(); |
6086
12
114