Do not work on git bash(windows)
keenwon opened this issue · 3 comments
keenwon commented
os: windows 7
terminal: git bash
cli.js
#!/usr/bin/env node
const size = require('window-size');
console.log(size);
$ node cli.js
{ width: 118, height: 39, type: 'stdout' }
# but
$ ./cli.js
undefined
doowb commented
@keenwon take a look this part of the readme
In some environments you need to use the utils
directly to get the window size:
const sizeUtils = require('window-size/utils');
console.log(sizeUtils.win());
I'm closing this since the library is working as expected. If you have an error, please open an issue with the stack trace.
keenwon commented
function winSize() {
if (os.release().startsWith('10')) {
var cmd = 'wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution';
var numberPattern = /\d+/g;
var code = cp.execSync(cmd).toString();
var size = code.match(numberPattern);
if (isSize(size)) {
return {
width: Number(size[0]),
height: Number(size[1]),
type: 'windows'
};
}
}
}
win()
looks like only support os release start with 10. Sadly, my problem occurs in Windows 7 git bash
doowb commented
Have you tried the other methods? If nothing works and you have an idea on how to get the window size in your environment a PR would be appreciated. I don't currently have Windows 7 to test on.