gotwarlost / istanbul-middleware

Connect middleware for server side code coverage using istanbul
Other
179 stars 96 forks source link

can not getInstrumenter when write my own custom middleware #27

Open flyHe opened 8 years ago

flyHe commented 8 years ago

I write my own custom middleware.As in:

var im = require('istanbul-middleware'),
app.use(function (req, res, next) {
    if (isJSRequiringCoverage(req)) {
        var file = getFilePath(req), //it's ok
            code = readTheCodeFromFile(file),//it's ok
            instrumenter = im.getInstrumenter(); //TypeError: im.getInstrumenter is not a function
        res.send(instrumenter.instrumentSync(code, file));
            //exception handling omitted for brevity
    } else {
        next();
    }
});

the getInstrumenter function is defined in './core.js',I can not use it on im

flyHe commented 8 years ago

maybe the getInstrumenter should be exported in handlers.js

flyHe commented 8 years ago

Alright,I do it by myself requiring './core.js'

lenntt commented 7 years ago

I'm running into the same problem. does this relate to #15 ?