pax_global_header 0000666 0000000 0000000 00000000064 13515101624 0014510 g ustar 00root root 0000000 0000000 52 comment=b4b4bda46dc6a5c5b8e347b2561fd3625a927f8d
is-interactive-1.0.0/ 0000775 0000000 0000000 00000000000 13515101624 0014434 5 ustar 00root root 0000000 0000000 is-interactive-1.0.0/.editorconfig 0000664 0000000 0000000 00000000257 13515101624 0017115 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.yml]
indent_style = space
indent_size = 2
is-interactive-1.0.0/.gitattributes 0000664 0000000 0000000 00000000023 13515101624 0017322 0 ustar 00root root 0000000 0000000 * text=auto eol=lf
is-interactive-1.0.0/.github/ 0000775 0000000 0000000 00000000000 13515101624 0015774 5 ustar 00root root 0000000 0000000 is-interactive-1.0.0/.github/funding.yml 0000664 0000000 0000000 00000000133 13515101624 0020146 0 ustar 00root root 0000000 0000000 github: sindresorhus
open_collective: sindresorhus
custom: https://sindresorhus.com/donate
is-interactive-1.0.0/.gitignore 0000664 0000000 0000000 00000000027 13515101624 0016423 0 ustar 00root root 0000000 0000000 node_modules
yarn.lock
is-interactive-1.0.0/.npmrc 0000664 0000000 0000000 00000000023 13515101624 0015547 0 ustar 00root root 0000000 0000000 package-lock=false
is-interactive-1.0.0/.travis.yml 0000664 0000000 0000000 00000000065 13515101624 0016546 0 ustar 00root root 0000000 0000000 language: node_js
node_js:
- '12'
- '10'
- '8'
is-interactive-1.0.0/index.d.ts 0000664 0000000 0000000 00000001315 13515101624 0016335 0 ustar 00root root 0000000 0000000 ///
declare namespace isInteractive {
interface Options {
/**
The stream to check.
@default process.stdout
*/
readonly stream?: NodeJS.WritableStream;
}
}
/**
Check if stdout or stderr is [interactive](https://unix.stackexchange.com/a/43389/7678).
It checks that the stream is [TTY](https://jameshfisher.com/2017/12/09/what-is-a-tty/), not a dumb terminal, and not running in a CI.
This can be useful to decide whether to present interactive UI or animations in the terminal.
@example
```
import isInteractive = require('is-interactive');
isInteractive();
//=> true
```
*/
declare function isInteractive(options?: isInteractive.Options): boolean;
export = isInteractive;
is-interactive-1.0.0/index.js 0000664 0000000 0000000 00000000264 13515101624 0016103 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ({stream = process.stdout} = {}) => {
return Boolean(
stream && stream.isTTY &&
process.env.TERM !== 'dumb' &&
!('CI' in process.env)
);
};
is-interactive-1.0.0/index.test-d.ts 0000664 0000000 0000000 00000000207 13515101624 0017311 0 ustar 00root root 0000000 0000000 import {expectType} from 'tsd';
import isInteractive = require('.');
expectType(isInteractive({
stream: process.stderr
}));
is-interactive-1.0.0/license 0000664 0000000 0000000 00000002125 13515101624 0016001 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) Sindre Sorhus (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:
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.
is-interactive-1.0.0/package.json 0000664 0000000 0000000 00000001173 13515101624 0016724 0 ustar 00root root 0000000 0000000 {
"name": "is-interactive",
"version": "1.0.0",
"description": "Check if stdout or stderr is interactive",
"license": "MIT",
"repository": "sindresorhus/is-interactive",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"interactive",
"stdout",
"stderr",
"detect",
"is",
"terminal",
"shell",
"tty"
],
"devDependencies": {
"@types/node": "^12.0.12",
"ava": "^2.1.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}
is-interactive-1.0.0/readme.md 0000664 0000000 0000000 00000003672 13515101624 0016223 0 ustar 00root root 0000000 0000000 # is-interactive [](https://travis-ci.com/sindresorhus/is-interactive)
> Check if stdout or stderr is [interactive](https://unix.stackexchange.com/a/43389/7678)
It checks that the stream is [TTY](https://jameshfisher.com/2017/12/09/what-is-a-tty/), not a dumb terminal, and not running in a CI.
This can be useful to decide whether to present interactive UI or animations in the terminal.
## Install
```
$ npm install is-interactive
```
## Usage
```js
const isInteractive = require('is-interactive');
isInteractive();
//=> true
```
## API
### isInteractive(options?)
#### options
Type: `object`
##### stream
Type: [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable)
Default: [`process.stdout`](https://nodejs.org/api/process.html#process_process_stdout)
The stream to check.
## FAQ
#### Why are you not using [`ci-info`](https://github.com/watson/ci-info) for the CI check?
It's silly to have to detect individual CIs. They should identify themselves with the `CI` environment variable, and most do just that. A manually maintained list of detections will easily get out of date. And if a package using `ci-info` doesn't update to the latest version all the time, they will not support certain CIs. It also creates unpredictability as you might assume a CI is not supported and then suddenly it gets supported and you didn't account for that. In addition, some of the manual detections are loose and might cause false-positives which could create hard-to-debug bugs.
#### Why does this even exist? It's just a few lines.
It's not about the number of lines, but rather discoverability and documentation. A lot of people wouldn't even know they need this. Feel free to copy-paste the code if you don't want the dependency. You might also want to read [this blog post](https://blog.sindresorhus.com/small-focused-modules-9238d977a92a).
is-interactive-1.0.0/test.js 0000664 0000000 0000000 00000001074 13515101624 0015753 0 ustar 00root root 0000000 0000000 import {PassThrough as PassThroughStream} from 'stream';
import test from 'ava';
import isInteractive from '.';
test('tty', t => {
const ci = process.env.CI;
delete process.env.CI;
const stream = new PassThroughStream();
stream.isTTY = true;
t.true(isInteractive({stream}));
process.env.CI = ci;
});
test('non-tty', t => {
const stream = new PassThroughStream();
stream.isTTY = false;
t.false(isInteractive({stream}));
});
test('dumb', t => {
const term = process.env.TERM;
process.env.TERM = 'dumb';
t.false(isInteractive());
process.env.TERM = term;
});