Open Kikobeats opened 9 years ago
No. I'm doing (almost) exactly this, and I'm not seeing this issue. The error is in mkdirs
, too, which is supposed to be creating folders. Is $PWD
in fact, the current working directory here? Or is this part of a script that's setting $PWD
and then changing the directory?
You can add some debug logging in ./node_modules/coffee-coverage/lib/helpers.js, inside exports.mkdirs()
, and see if you can figure out the full path of the folder it's trying to create. Feels like some kind of relative path problem...
You're right. Some debug logs before call mkdirs
method:
if (options.writeOnExit) {
return process.on('exit', function() {
var dirName, ref1;
try {
dirName = path.dirname(options.writeOnExit);
console.log('DEBUG ::');
console.log(dirName);
console.log(process.cwd());
console.log(__dirname);
mkdirs(dirName);
return fs.writeFileSync(options.writeOnExit, JSON.stringify(global[options.coverageVar]));
output:
DEBUG ::
coverage
/Users/josefranciscoverdugambin/Projects/bumped/bumped/test/plugin_directory
/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib
Failed to write coverage data Error: ENOENT, no such file or directory 'coverage/'
at Object.fs.mkdirSync (fs.js:654:18)
at exports.mkdirs (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/utils/helpers.js:48:14)
at process.<anonymous> (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/register.js:154:11)
at process.emit (events.js:95:17)
at process.exit (node.js:740:17)
at done (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/mocha/bin/_mocha:406:32)
at afterWrite (_stream_writable.js:278:3)
at _stream_writable.js:267:9
at process._tickCallback (node.js:448:13)
I suppose that is important that I'm running the command using a script. I have the script in test/test.sh
, so when I call the script from the root of my project using npm test
could be a conflict with process.cwd
and/or __dirname
...
I really don't know why this happens.
I use a shellscript to run the tests:
You can see all the code here
The problem is that
--require coffee-coverage/register-istanbul
line throw an Error related with the coverage folder:the strange thing is that the folder doesn't exist before I run the script (good) and after the exceptions exists.
Any idea of what happens?