broccoli-content-funnel
Advanced tools
Comparing version 0.0.1 to 0.0.2
31
index.js
@@ -6,3 +6,5 @@ 'use strict'; | ||
const denodeify = require('denodeify'); | ||
const readFile = denodeify(require('fs').readFile); | ||
const fs = require('fs'); | ||
const readFile = denodeify(fs.readFile); | ||
const realpath = denodeify(fs.realpath); | ||
@@ -37,10 +39,15 @@ class ContentFunnel extends Funnel { | ||
.on('data', item => { | ||
if (item.stats.isDirectory()) { | ||
return; | ||
} | ||
let promise; | ||
if (type === 'function') { | ||
promise = Promise.resolve(this.options[option](item.path)); | ||
} else { | ||
promise = readFile(item.path, 'utf8').then(source => { | ||
promises.push(Promise.resolve().then(() => { | ||
if (item.stats.isSymbolicLink()) { | ||
return realpath(item.path); | ||
} | ||
return item.path; | ||
}).then(filePath => { | ||
if (item.stats.isDirectory()) { | ||
return; | ||
} | ||
if (type === 'function') { | ||
return this.options[option](filePath); | ||
} | ||
return readFile(filePath, 'utf8').then(source => { | ||
if (type === 'string') { | ||
@@ -51,9 +58,7 @@ return source.indexOf(this.options[option]) !== -1; | ||
}); | ||
} | ||
promise = promise.then(result => { | ||
}).then(result => { | ||
if (result) { | ||
this[option].push(item.path.substr(inputPath.length + 1)); | ||
} | ||
}); | ||
promises.push(promise); | ||
})); | ||
}) | ||
@@ -60,0 +65,0 @@ .on('end', () => { |
{ | ||
"name": "broccoli-content-funnel", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Funnel based on file contents", | ||
@@ -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
4642
66