UNPKG

ls-lint

Version:
52 lines (51 loc) 1.63 kB
(function(){ var globAll, fs, ref$, map, flatten, empty, lsLint, println, reportLintFile, lintFile, slice$ = [].slice; globAll = require('glob-all'); fs = require('fs'); ref$ = require('prelude-ls'), map = ref$.map, flatten = ref$.flatten, empty = ref$.empty; lsLint = require('./ls-lint'); println = require('./reporters/report-utils').println; reportLintFile = require('./reporters/report-lint-file'); module.exports = function(paths, opts){ var this$ = this; println(''); return function(it){ return it.then(flatten); }( Promise.all( map(partialize$.apply(this, [lintFile, [void 8, opts], [0]]))( globAll.sync(paths)))); }; lintFile = function(file, opts){ return new Promise(function(resolve, reject){ return fs.readFile(file, { encoding: 'utf8' }, function(err, data){ var e; if (err) { return reject(err); } else { try { return resolve( reportLintFile(file)( lsLint.lint(data, opts))); } catch (e$) { e = e$; return reject(e); } } }); }); }; function partialize$(f, args, where){ var context = this; return function(){ var params = slice$.call(arguments), i, len = params.length, wlen = where.length, ta = args ? args.concat() : [], tw = where ? where.concat() : []; for(i = 0; i < len; ++i) { ta[tw[0]] = params[i]; tw.shift(); } return len < wlen && len ? partialize$.apply(context, [f, ta, tw]) : f.apply(context, ta); }; } }).call(this);