sindresorhus/meow

meow does something strange with GL

mifi opened this issue · 7 comments

mifi commented

I create a new directory then yarn add gl meow

const GL = require('gl');
const meow = require('meow');

// meow('foo');

const gl = GL(800, 600);
console.log(gl != null);

This prints true - all ok.

However when I uncomment meow('foo'), I get false. So for some reason GL returns null now. Will look more into it, but maybe you have an idea. Is meow doing any global changes to the node environment?

The only thing I can think of is

meow/index.js

Lines 13 to 15 in 2954ed2

// Prevent caching of this module so module.parent is always accurate
delete require.cache[__filename];
const parentDir = path.dirname(module.parent.filename);
. Try commenting that out.

mifi commented

I tried to comment out the "delete" line, didn't help

papb commented

Hello, I happen to watch this repository and this issue surprised me. I tried to reproduce it but could not. I got true as output in both cases. The only difference is that I used npm instead of yarn.

EDIT: used yarn, still getting true in both cases.

mifi commented

I did some binary search code elimination and I found that what's causing it is this line:

meow/index.js

Line 80 in 2954ed2

process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;

@papb which OS are you on?

So basically the way to reproduce this is:

const GL = require('gl');

process.title = 'foo'

const gl = GL(320, 240);
console.log(gl != null)

Returns false

If I comment out process.title = 'foo', returns true

mifi commented

Now I found this issue: stackgl/headless-gl#180

mifi commented

As suggested there I upgraded to node v12.16.2 and now it works. I was running v12.11.1 before.

papb commented

I am on windows, node v12.14.1