Comparing version 0.1.0 to 0.1.1
35
index.js
'use strict'; | ||
var q = require('q'); | ||
var shell = require('shelljs/global'); | ||
var async = require('async'); | ||
var cache = require('./lib/cache'); | ||
var linter = require('./lib/linter'); | ||
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) { | ||
@@ -44,5 +15,5 @@ var deferred = q.defer(); | ||
var limit = options.limit ? options.limit : 10; | ||
stdout = options.stdout ? options.stdout : false; | ||
linter.stdout = options.stdout ? options.stdout : false; | ||
async.eachLimit(result, limit, linter, function (err) { | ||
async.eachLimit(result, limit, linter.lint.bind(linter), function (err) { | ||
if (err) return deferred.reject(new Error(err.trim())); | ||
@@ -49,0 +20,0 @@ |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var _ = require('lodash'); | ||
@@ -2,0 +4,0 @@ var glob = require('glob'); |
{ | ||
"name": "phplint", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "wrapper for php -l", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6261
13
120