window-size
Advanced tools
Comparing version 0.2.0 to 0.3.0
12
index.js
@@ -11,2 +11,4 @@ 'use strict'; | ||
var tty = require('tty'); | ||
var os = require('os'); | ||
var execSync = require('child_process').execSync; | ||
@@ -17,3 +19,3 @@ module.exports = (function () { | ||
if (tty.isatty(1) && tty.isatty(2)) { | ||
if (tty.isatty(1)) { | ||
if (process.stdout.getWindowSize) { | ||
@@ -29,4 +31,10 @@ width = process.stdout.getWindowSize(1)[0]; | ||
} | ||
} else if (os.release().startsWith('10')) { | ||
var numberPattern = /\d+/g; | ||
var cmd = 'wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution'; | ||
var code = execSync(cmd).toString('utf8'); | ||
var res = code.match(numberPattern); | ||
return { height: ~~res[1], width: ~~res[0] }; | ||
} else { | ||
Error('window-size could not get size with tty or process.stdout.'); | ||
return { height: undefined, width: undefined }; | ||
} | ||
@@ -33,0 +41,0 @@ |
{ | ||
"name": "window-size", | ||
"description": "Reliable way to to get the height and width of the terminal/console in a node.js environment.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/jonschlinkert/window-size", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"contributors": [ | ||
"Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)", | ||
"Carlos Hernández Gómez (https://github.com/karliky)", | ||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)", | ||
"Siddharth Kannan <kannan.siddharth12@gmail.com> (http://www.icyflame.me)" | ||
], | ||
"repository": "jonschlinkert/window-size", | ||
@@ -13,6 +19,7 @@ "bugs": { | ||
"files": [ | ||
"index.js", | ||
"cli.js" | ||
"cli.js", | ||
"index.js" | ||
], | ||
"main": "index.js", | ||
"bin": "cli.js", | ||
"engines": { | ||
@@ -22,9 +29,8 @@ "node": ">= 0.10.0" | ||
"scripts": { | ||
"pretest": "semistandard", | ||
"test": "tap --coverage test.js" | ||
}, | ||
"bin": "cli.js", | ||
"devDependencies": { | ||
"semistandard": "^7.0.2", | ||
"tap": "^2.2.1" | ||
"gulp-format-md": "^0.1.11", | ||
"semistandard": "^9.2.1", | ||
"tap": "^8.0.1" | ||
}, | ||
@@ -44,8 +50,23 @@ "keywords": [ | ||
"list": [ | ||
"yargs", | ||
"base-cli", | ||
"lint-deps", | ||
"base-cli" | ||
"yargs" | ||
] | ||
} | ||
}, | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"lint": { | ||
"reflinks": true | ||
}, | ||
"reflinks": [ | ||
"verb", | ||
"verb-generate-readme" | ||
] | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# window-size [![NPM version](https://badge.fury.io/js/window-size.svg)](http://badge.fury.io/js/window-size) [![Build Status](https://travis-ci.org/jonschlinkert/window-size.svg)](https://travis-ci.org/jonschlinkert/window-size) | ||
# window-size [![NPM version](https://img.shields.io/npm/v/window-size.svg?style=flat)](https://www.npmjs.com/package/window-size) [![NPM monthly downloads](https://img.shields.io/npm/dm/window-size.svg?style=flat)](https://npmjs.org/package/window-size) [![NPM total downloads](https://img.shields.io/npm/dt/window-size.svg?style=flat)](https://npmjs.org/package/window-size) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/window-size.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/window-size) | ||
@@ -7,6 +7,6 @@ > Reliable way to to get the height and width of the terminal/console in a node.js environment. | ||
Install with [npm](https://www.npmjs.com/) | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm i window-size --save | ||
$ npm install --save window-size | ||
``` | ||
@@ -22,26 +22,55 @@ | ||
## Other projects | ||
## About | ||
* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://www.npmjs.com/package/base-cli) | [homepage](https://github.com/jonschlinkert/base-cli) | ||
* [lint-deps](https://www.npmjs.com/package/lint-deps): CLI tool that tells you when dependencies are missing from package.json and offers you a… [more](https://www.npmjs.com/package/lint-deps) | [homepage](https://github.com/jonschlinkert/lint-deps) | ||
* [yargs](https://www.npmjs.com/package/yargs): Light-weight option parsing with an argv hash. No optstrings attached. | [homepage](https://github.com/bcoe/yargs#readme) | ||
### Related projects | ||
## Contributing | ||
* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://github.com/node-base/base-cli) | [homepage](https://github.com/node-base/base-cli "Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.") | ||
* [lint-deps](https://www.npmjs.com/package/lint-deps): CLI tool that tells you when dependencies are missing from package.json and offers you a… [more](https://github.com/jonschlinkert/lint-deps) | [homepage](https://github.com/jonschlinkert/lint-deps "CLI tool that tells you when dependencies are missing from package.json and offers you a choice to install them. Also tells you when dependencies are listed in package.json but are not being used anywhere in your project. Node.js command line tool and API") | ||
* [yargs](https://www.npmjs.com/package/yargs): yargs the modern, pirate-themed, successor to optimist. | [homepage](http://yargs.js.org/ "yargs the modern, pirate-themed, successor to optimist.") | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/window-size/issues/new). | ||
### Contributing | ||
## Author | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Contributors | ||
| **Commits** | **Contributor**<br/> | | ||
| --- | --- | | ||
| 16 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 4 | [bcoe](https://github.com/bcoe) | | ||
| 3 | [icyflame](https://github.com/icyflame) | | ||
| 1 | [karliky](https://github.com/karliky) | | ||
### Building docs | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
``` | ||
### Running tests | ||
Install dev dependencies: | ||
```sh | ||
$ npm install -d && npm test | ||
``` | ||
### Author | ||
**Jon Schlinkert** | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
### License | ||
Copyright © 2014-2015 [Jon Schlinkert](https://github.com/jonschlinkert) | ||
Released under the MIT license. | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/window-size/blob/master/LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 15, 2015._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on December 10, 2016._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7738
63
74
3
1