I am completing exercise 6 for students at school.io learnyounode, makeitmodular.
I am getting the correct results, but there is still an error regarding a piece of code that I am not familiar with. Any help would be great.
Below are the results and errors:
Your submission results compared to the expected:
ACTUAL EXPECTED
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"CHANGELOG.md" == "CHANGELOG.md"
"LICENCE.md" == "LICENCE.md"
"README.md" == "README.md"
"" == ""
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
/usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:182
processors[i].call(self, mode, function (err, pass) {
^
TypeError: Cannot read property 'call' of undefined
at next (/usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:182:18)
at /usr/local/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:189:7
at callback (/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:26:15)
at modFileError (/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:31:5)
at /usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:119:18
at /Users/Olly/workspace/learnyounode/mymodule.js:13:13
at Array.forEach (native)
at /Users/Olly/workspace/learnyounode/mymodule.js:11:9
at FSReqWrap.oncomplete (fs.js:82:15)
My makeitmodular.js file:
var dir = process.argv[2];
var filter = process.argv[3];
var mymodule = require('./mymodule.js')
mymodule (dir,filter, function (err, data) {
if (err) {
console.log("There was an error")
}
else {
console.log(data)
}
})
My module.js file:
var fs = require('fs')
var path = require('path');
module.exports = function(dir, filter, callback) {
fs.readdir(dir, function (err, list) {
if (err) {
return callback(err)
}
else {
list.forEach( function(file) {
if ( path.extname(file) === '.' + filter ) {
return callback(null, file)
}
})
}
})
};
source
share