Last active
June 21, 2016 11:24
-
-
Save gotwarlost/e203dff7e14bb8234fb8c48db5a61d7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {realpathSync} from 'fs'; | |
import {programVisitor} from 'istanbul-lib-instrument'; | |
function getRealpath(n) { | |
try { | |
return realpathSync(n) || n | |
} catch (e) { | |
return n | |
} | |
} | |
function shouldSkip(file) { | |
return false; | |
} | |
function makeVisitor({types: t}) { | |
return { | |
visitor: { | |
Program: { | |
enter(path) { | |
this.__dv__ = null; | |
const realPath = getRealpath(this.file.opts.filename); | |
if (shouldSkip(realPath)) { | |
return; | |
} | |
this.__dv__ = programVisitor(t, realPath); | |
this.__dv__.enter(path); | |
}, | |
exit(path) { | |
if (!this.__dv__) { | |
return; | |
} | |
this.__dv__.exit(path); | |
} | |
} | |
} | |
}; | |
} | |
export default makeVisitor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment