istanbul-middleware icon indicating copy to clipboard operation
istanbul-middleware copied to clipboard

can not getInstrumenter when write my own custom middleware

Open flyHe opened this issue 8 years ago • 3 comments

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 avatar Apr 07 '16 02:04 flyHe

maybe the getInstrumenter should be exported in handlers.js

flyHe avatar Apr 07 '16 02:04 flyHe

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

flyHe avatar Apr 25 '16 02:04 flyHe

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

lenntt avatar Apr 03 '17 10:04 lenntt