New Upstream Snapshot - node-term-size

Ready changes

Summary

Merged new upstream version: 3.0.2+dfsg (was: 1.2.0+dfsg).

Resulting package

Built on 2023-01-11T03:19 (took 7m8s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots node-term-size

Diff

diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index 98a761d..0000000
--- a/.editorconfig
+++ /dev/null
@@ -1,12 +0,0 @@
-root = true
-
-[*]
-indent_style = tab
-end_of_line = lf
-charset = utf-8
-trim_trailing_whitespace = true
-insert_final_newline = true
-
-[{package.json,*.yml}]
-indent_style = space
-indent_size = 2
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 391f0a4..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-* text=auto
-*.js text eol=lf
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 3c3629e..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-node_modules
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index bd9dc67..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-os:
-  - linux
-  - osx
-language: node_js
-node_js:
-  - '6'
-  - '4'
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index bdcf273..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-environment:
-  matrix:
-    - nodejs_version: '6'
-    - nodejs_version: '4'
-install:
-  - ps: Install-Product node $env:nodejs_version
-  - set CI=true
-  - npm -g install npm@latest
-  - set PATH=%APPDATA%\npm;%PATH%
-  - npm install
-matrix:
-  fast_finish: true
-build: off
-version: '{build}'
-shallow_clone: true
-clone_depth: 1
-test_script:
-  - node --version
-  - npm --version
-  - npm test
diff --git a/debian/changelog b/debian/changelog
index 48a56df..a1c7f7d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
-node-term-size (1.2.0+dfsg-5) UNRELEASED; urgency=medium
+node-term-size (3.0.2+dfsg-1) UNRELEASED; urgency=medium
 
   * Update standards version to 4.6.2, no changes needed.
+  * New upstream release.
 
- -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 01:43:49 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 03:15:32 -0000
 
 node-term-size (1.2.0+dfsg-4) unstable; urgency=medium
 
diff --git a/fixture.js b/fixture.js
deleted file mode 100644
index c52536b..0000000
--- a/fixture.js
+++ /dev/null
@@ -1,5 +0,0 @@
-'use strict';
-const termSize = require('./');
-
-const size = termSize();
-console.log(`${size.columns}\n${size.rows}`);
diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index 0000000..d32ec33
--- /dev/null
+++ b/index.d.ts
@@ -0,0 +1,17 @@
+export interface TerminalSize {
+	columns: number;
+	rows: number;
+}
+
+/**
+Reliably get the terminal window size.
+
+@example
+```
+import terminalSize from 'term-size';
+
+terminalSize();
+//=> {columns: 143, rows: 24}
+```
+*/
+export default function terminalSize(): TerminalSize;
diff --git a/index.js b/index.js
index 95e410d..617a2e2 100644
--- a/index.js
+++ b/index.js
@@ -1,16 +1,23 @@
-'use strict';
-const path = require('path');
-const execa = require('execa');
+import process from 'node:process';
+import {execFileSync} from 'node:child_process';
+import path from 'node:path';
+import {fileURLToPath} from 'node:url';
+
+const exec = (command, arguments_, shell) =>
+	execFileSync(command, arguments_, {encoding: 'utf8', shell, stdio: ['ignore', 'pipe', 'ignore']}).trim();
+
+function execNative(command, shell) {
+	const __dirname = path.dirname(fileURLToPath(import.meta.url));
+	return exec(path.join(__dirname, command), [], shell).split(/\r?\n/);
+}
 
 const create = (columns, rows) => ({
-	columns: parseInt(columns, 10),
-	rows: parseInt(rows, 10)
+	columns: Number.parseInt(columns, 10),
+	rows: Number.parseInt(rows, 10),
 });
 
-module.exports = () => {
-	const env = process.env;
-	const stdout = process.stdout;
-	const stderr = process.stderr;
+export default function terminalSize() {
+	const {env, stdout, stderr} = process;
 
 	if (stdout && stdout.columns && stdout.rows) {
 		return create(stdout.columns, stdout.rows);
@@ -28,43 +35,45 @@ module.exports = () => {
 	if (process.platform === 'win32') {
 		try {
 			// Binary: https://github.com/sindresorhus/win-term-size
-			const size = execa.sync(path.join(__dirname, 'vendor/windows/term-size.exe')).stdout.split(/\r?\n/);
+			const size = execNative('vendor/windows/term-size.exe', false);
 
 			if (size.length === 2) {
 				return create(size[0], size[1]);
 			}
-		} catch (err) {}
+		} catch {}
 	} else {
 		if (process.platform === 'darwin') {
 			try {
 				// Binary: https://github.com/sindresorhus/macos-term-size
-				const size = execa.shellSync(path.join(__dirname, 'vendor/macos/term-size')).stdout.split(/\r?\n/);
+				const size = execNative('vendor/macos/term-size', true);
 
 				if (size.length === 2) {
 					return create(size[0], size[1]);
 				}
-			} catch (err) {}
+			} catch {}
 		}
 
 		// `resize` is preferred as it works even when all file descriptors are redirected
 		// https://linux.die.net/man/1/resize
 		try {
-			const size = execa.sync('resize', ['-u']).stdout.match(/\d+/g);
+			const size = exec('resize', ['-u']).match(/\d+/g);
 
 			if (size.length === 2) {
 				return create(size[0], size[1]);
 			}
-		} catch (err) {}
+		} catch {}
 
-		try {
-			const columns = execa.sync('tput', ['cols']).stdout;
-			const rows = execa.sync('tput', ['lines']).stdout;
+		if (process.env.TERM) {
+			try {
+				const columns = exec('tput', ['cols']);
+				const rows = exec('tput', ['lines']);
 
-			if (columns && rows) {
-				return create(columns, rows);
-			}
-		} catch (err) {}
+				if (columns && rows) {
+					return create(columns, rows);
+				}
+			} catch {}
+		}
 	}
 
 	return create(80, 24);
-};
+}
diff --git a/license b/license
index 654d0bf..fa7ceba 100644
--- a/license
+++ b/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
 
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/package.json b/package.json
index 798d7eb..8e072ac 100644
--- a/package.json
+++ b/package.json
@@ -1,43 +1,45 @@
 {
-  "name": "term-size",
-  "version": "1.2.0",
-  "description": "Reliably get the terminal window size (columns & rows)",
-  "license": "MIT",
-  "repository": "sindresorhus/term-size",
-  "author": {
-    "name": "Sindre Sorhus",
-    "email": "sindresorhus@gmail.com",
-    "url": "sindresorhus.com"
-  },
-  "engines": {
-    "node": ">=4"
-  },
-  "scripts": {
-    "test": "xo && ava"
-  },
-  "files": [
-    "index.js",
-    "vendor"
-  ],
-  "keywords": [
-    "term",
-    "terminal",
-    "size",
-    "console",
-    "window",
-    "width",
-    "height",
-    "columns",
-    "rows",
-    "lines",
-    "tty",
-    "redirected"
-  ],
-  "dependencies": {
-    "execa": "^0.7.0"
-  },
-  "devDependencies": {
-    "ava": "*",
-    "xo": "*"
-  }
+	"name": "term-size",
+	"version": "3.0.2",
+	"description": "Reliably get the terminal window size (columns & rows)",
+	"license": "MIT",
+	"repository": "sindresorhus/term-size",
+	"funding": "https://github.com/sponsors/sindresorhus",
+	"author": {
+		"name": "Sindre Sorhus",
+		"email": "sindresorhus@gmail.com",
+		"url": "https://sindresorhus.com"
+	},
+	"type": "module",
+	"exports": "./index.js",
+	"engines": {
+		"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+	},
+	"scripts": {
+		"test": "xo && ava && tsd"
+	},
+	"files": [
+		"index.js",
+		"index.d.ts",
+		"vendor"
+	],
+	"keywords": [
+		"terminal",
+		"size",
+		"console",
+		"window",
+		"width",
+		"height",
+		"columns",
+		"rows",
+		"lines",
+		"tty",
+		"redirected"
+	],
+	"devDependencies": {
+		"ava": "^3.15.0",
+		"execa": "^5.1.1",
+		"tsd": "^0.17.0",
+		"xo": "^0.44.0"
+	}
 }
diff --git a/readme.md b/readme.md
index dd642ca..16a2245 100644
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,4 @@
-# term-size [![Build Status: Linux & macOS](https://travis-ci.org/sindresorhus/term-size.svg?branch=master)](https://travis-ci.org/sindresorhus/term-size) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/c3tydg6uedsk0bob/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/term-size/branch/master)
+# term-size
 
 > Reliably get the terminal window size
 
@@ -6,36 +6,43 @@ Because [`process.stdout.columns`](https://nodejs.org/api/tty.html#tty_writestre
 
 Confirmed working on macOS, Linux, and Windows.
 
-
 ## Install
 
 ```
-$ npm install --save term-size
+$ npm install term-size
 ```
 
-
 ## Usage
 
 ```js
-const termSize = require('term-size');
+import terminalSize from 'term-size';
 
-termSize();
+terminalSize();
 //=> {columns: 143, rows: 24}
 ```
 
-
 ## API
 
-### termSize()
+### terminalSize()
 
-Returns an `Object` with `columns` and `rows` properties.
+Returns an `object` with `columns` and `rows` properties.
 
+## Info
+
+The bundled macOS binary is signed and hardened.
 
 ## Related
 
 - [term-size-cli](https://github.com/sindresorhus/term-size-cli) - CLI for this module
 
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
+---
+
+<div align="center">
+	<b>
+		<a href="https://tidelift.com/subscription/pkg/npm-term-size?utm_source=npm-term-size&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+	</b>
+	<br>
+	<sub>
+		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+	</sub>
+</div>
diff --git a/test.js b/test.js
deleted file mode 100644
index 8cfad14..0000000
--- a/test.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import test from 'ava';
-import execa from 'execa';
-import m from './';
-
-test('main', t => {
-	const size = m();
-	console.log('main size:', size);
-	t.true(size.columns > 0);
-	t.true(size.rows > 0);
-});
-
-test('child', async t => {
-	const [columns, rows] = (await execa.stdout('node', ['fixture.js'])).split('\n').map(Number);
-	console.log('child size:', {columns, rows});
-	t.true(parseInt(columns, 10) > 0);
-	t.true(parseInt(rows, 10) > 0);
-});
diff --git a/vendor/macos/term-size b/vendor/macos/term-size
new file mode 100755
index 0000000..a18b59a
Binary files /dev/null and b/vendor/macos/term-size differ
diff --git a/vendor/windows/term-size.exe b/vendor/windows/term-size.exe
new file mode 100644
index 0000000..c7a170c
Binary files /dev/null and b/vendor/windows/term-size.exe differ

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/nodejs/term-size/index.d.ts
-rw-r--r--  root/root   /usr/share/nodejs/term-size/vendor/windows/term-size.exe
-rwxr-xr-x  root/root   /usr/share/nodejs/term-size/vendor/macos/term-size

No differences were encountered in the control files

More details

Full run details