Closed thealjey closed 8 years ago
Just had one comment @thealjey
@jmcriffey please check now
Cool, LGTM. Thanks!
Is there an example / documentation of how we can use this? Is it an option that we can add to the istanbul.yml? I can't seem to get it working with something like this in the terminal: ./node_modules/.bin/babel-istanbul --babel-config conf/babel.json
@danjford --babel-config
is a CLI option, you specify it like so:
--babel-config conf/babel.json
or
--babel-config conf/babel.yml
or
--babel-config conf/babel.js
The configuration object is passed directly to Babel.
What you need to check is the version of Babel that babel-istanbul uses and whether or not the configuration you provide to it is supported by that version of Babel.
What do you mean it's not working, does it not do anything or do you see an error?
What are the contents of conf/babel.json
?
I tried using the command ./node_modules/.bin/babel-istanbul --babel-config conf/babel.json cover ./node_modules/mocha/bin/_mocha
to cover my mocha tests. In this case it gave an error saying that conf/babel.json wasn't a command.
My babel.json contained:
{
"presets": [ "es2015" ]
}
The reason I was trying to change where the babel configurations were due to having a conflict with another library that didn't want "presets": [ "es2015" ]
in the .babelrc.
As I couldn't get the --babel-config option working with babel-istanbul I've just put a work around into the .babelrc so that it doesn't conflict with the other library. The work around I've done is specified the environment in the .babelrc file as tests
so that when I run the tests I just set NODE_ENV=tests
, which means the conflicting library will not read the presets.
@danjford
duh, try this
babel-istanbul cover --babel-config conf/babel.json ./node_modules/mocha/bin/_mocha
babel-istanbul needs a command first, that's why it told you that it wasn't a valid "command" :smiley_cat:
Running ./node_modules/.bin/babel-istanbul
would be the same as babel-istanbul
except one is installed to a project and the other is installed globally :p
I'm looking back and I've tried replicating the issue but for some reason the command that I mentioned in the previous comment works now... so never mind lol :+1:
@danjford, that's not the point, you noticed that there's babel-istanbul
instead of ./node_modules/.bin/babel-istanbul
(which is basically the same fking thing), but you didn't notice that cover
was right after it.
That's the reason :laughing:
Ah my mistake, I think it's actually that I left out the =
as it would work as ./node_modules/.bin/babel-istanbul --babel-config=conf/babel.json cover ./node_modules/mocha/bin/_mocha
.
The
--babel-config
CLI option lets you set a specific configuration file to use for babel. It's an alternative to.babelrc
, but it can be located anywhere, so one does not have to rely on Babel searching the file system for it. Supports .yaml, .yml, .json and .js files.