Skip to content

Commit

Permalink
Require Node.js 18
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 22, 2024
1 parent 9e2071c commit 55563c7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
node_modules
yarn.lock
.tsimp
35 changes: 19 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"default": "./build/index.js"
},
"engines": {
"node": ">=14.16"
"node": ">=18"
},
"scripts": {
"prepare": "tsc",
Expand All @@ -31,20 +31,20 @@
"test"
],
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^18.0.0",
"@vdemedes/prettier-config": "^1.0.1",
"ava": "^5.1.1",
"delay": "^5.0.0",
"@sindresorhus/tsconfig": "^5.0.0",
"@types/react": "^18.3.2",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^6.1.3",
"delay": "^6.0.0",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink": "^4.0.0",
"prettier": "^2.0.4",
"react": "^18.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"xo": "^0.53.0"
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"ink": "^5.0.0",
"prettier": "^3.2.5",
"react": "^18.3.1",
"tsimp": "^2.0.11",
"typescript": "^5.4.5",
"xo": "^0.58.0"
},
"peerDependencies": {
"@types/react": ">=18.0.0"
Expand All @@ -60,12 +60,15 @@
"tsx": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
"--import=tsimp"
]
},
"xo": {
"extends": "xo-react",
"prettier": true
"prettier": true,
"rules": {
"unicorn/prefer-event-target": "off"
}
},
"prettier": "@vdemedes/prettier-config"
}
16 changes: 7 additions & 9 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {EventEmitter} from 'node:events';
import {render as inkRender} from 'ink';
import type {Instance as InkInstance} from 'ink';
import {render as inkRender, type Instance as InkInstance} from 'ink';
import type {ReactElement} from 'react';

class Stdout extends EventEmitter {
Expand Down Expand Up @@ -34,7 +33,7 @@ class Stderr extends EventEmitter {
class Stdin extends EventEmitter {
// eslint-disable-next-line @typescript-eslint/naming-convention
isTTY = true;
data: string | null = null;
data: string | null = null; // eslint-disable-line @typescript-eslint/ban-types
constructor(options: {isTTY?: boolean} = {}) {
super();
this.isTTY = options.isTTY ?? true;
Expand All @@ -43,7 +42,7 @@ class Stdin extends EventEmitter {
write = (data: string) => {
this.data = data;
this.emit('readable');
// this.emit('data', data);
this.emit('data', data);
};

setEncoding() {
Expand All @@ -70,11 +69,10 @@ class Stdin extends EventEmitter {
// Do nothing
}

// eslint-disable-next-line @typescript-eslint/ban-types
read: () => string | null = () => {
const data = this.data;

const {data} = this;
this.data = null;

return data;
};
}
Expand Down Expand Up @@ -106,7 +104,7 @@ export const render = (tree: ReactElement): Instance => {
stdin: stdin as any,
debug: true,
exitOnCtrlC: false,
patchConsole: false
patchConsole: false,
});

instances.push(instance);
Expand All @@ -119,7 +117,7 @@ export const render = (tree: ReactElement): Instance => {
stderr,
stdin,
frames: stdout.frames,
lastFrame: stdout.lastFrame
lastFrame: stdout.lastFrame,
};
};

Expand Down
2 changes: 1 addition & 1 deletion test/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('render a single frame', t => {
});

test('render multiple frames', t => {
function Counter({count}: {count: number}) {
function Counter({count}: {readonly count: number}) {
return <Text>Count: {count}</Text>;
}

Expand Down
11 changes: 5 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"outDir": "build",
"sourceMap": true
"sourceMap": true,
"jsx": "react"
},
"include": ["source"],
"ts-node": {
"transpileOnly": true,
"files": true
}
"include": [
"source"
]
}

0 comments on commit 55563c7

Please sign in to comment.