New Upstream Release - 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:22 (took 8m2s)

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

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

Lintian Result

Diff

diff --git a/.editorconfig b/.editorconfig
index 98a761d..1c6314a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,6 +7,6 @@ charset = utf-8
 trim_trailing_whitespace = true
 insert_final_newline = true
 
-[{package.json,*.yml}]
+[*.yml]
 indent_style = space
 indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index 391f0a4..6313b56 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1 @@
-* text=auto
-*.js text eol=lf
+* text=auto eol=lf
diff --git a/.github/funding.yml b/.github/funding.yml
new file mode 100644
index 0000000..c0151fa
--- /dev/null
+++ b/.github/funding.yml
@@ -0,0 +1,4 @@
+github: sindresorhus
+open_collective: sindresorhus
+tidelift: npm/term-size
+custom: https://sindresorhus.com/donate
diff --git a/.github/security.md b/.github/security.md
new file mode 100644
index 0000000..5358dc5
--- /dev/null
+++ b/.github/security.md
@@ -0,0 +1,3 @@
+# Security Policy
+
+To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..1442905
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,23 @@
+name: CI
+on:
+  - push
+  - pull_request
+jobs:
+  test:
+    name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        node-version:
+          - 16
+        os:
+          - ubuntu-latest
+          - windows-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v2
+        with:
+          node-version: ${{ matrix.node-version }}
+      - run: npm install
+      - run: npm test
diff --git a/.gitignore b/.gitignore
index 3c3629e..239ecff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 node_modules
+yarn.lock
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..43c97e7
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock=false
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..e9d4861 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:16:04 -0000
 
 node-term-size (1.2.0+dfsg-4) unstable; urgency=medium
 
diff --git a/fixture.js b/fixture.js
index c52536b..6460c4f 100644
--- a/fixture.js
+++ b/fixture.js
@@ -1,5 +1,4 @@
-'use strict';
-const termSize = require('./');
+import terminalSize from './index.js';
 
-const size = termSize();
-console.log(`${size.columns}\n${size.rows}`);
+const {columns, rows} = terminalSize();
+console.log(`${columns}\n${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/index.test-d.ts b/index.test-d.ts
new file mode 100644
index 0000000..24482be
--- /dev/null
+++ b/index.test-d.ts
@@ -0,0 +1,6 @@
+import {expectType} from 'tsd';
+import terminalSize, {TerminalSize} from './index.js';
+
+const size: TerminalSize = terminalSize();
+expectType<number>(size.columns);
+expectType<number>(size.rows);
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
index 8cfad14..f2a18ec 100644
--- a/test.js
+++ b/test.js
@@ -1,17 +1,30 @@
+import process from 'node:process';
 import test from 'ava';
 import execa from 'execa';
-import m from './';
+import terminalSize from './index.js';
 
 test('main', t => {
-	const size = m();
-	console.log('main size:', size);
+	const size = terminalSize();
+	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);
+	const {stdout} = await execa('node', ['fixture.js']);
+	const [columns, rows] = stdout.split('\n').map(line => Number.parseInt(line, 10));
+	console.log('Child size:', {columns, rows});
+	t.true(Number.parseInt(columns, 10) > 0);
+	t.true(Number.parseInt(rows, 10) > 0);
+});
+
+test('no TERM environment variable', t => {
+	const envTerm = process.env.TERM;
+	process.env.TERM = undefined;
+	const size = terminalSize();
+	process.env.TERM = envTerm;
+
+	console.log('Size with no $TERM:', size);
+	t.true(size.columns > 0);
+	t.true(size.rows > 0);
 });

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

No differences were encountered in the control files

More details

Full run details