Skip to content

Commit b24167c

Browse files
committed
Update README.en.md
1 parent d02ed0b commit b24167c

1 file changed

Lines changed: 15 additions & 37 deletions

File tree

README.en.md

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ English | [简体中文](./README.md)
1111
- 💪 Multi-arch support: Supports major operating systems and CPU architectures
1212
- 🔧 Ready to use: No compilation needed, supports multiple package managers
1313

14-
> [!WARNING]
14+
> [!WARNING]
1515
> Currently only tested in Windows Node.js environment. Compatibility with other environments (Linux, macOS, etc.) needs to be verified by users. Feedback is welcome if you encounter any issues.
1616
1717
## Installation
@@ -88,49 +88,27 @@ This project is open-sourced under the MIT License. Thanks to the contributions
8888
## Usage Example
8989

9090
```typescript
91-
import * as os from 'node:os'
92-
import * as pty from '@karinjs/node-pty'
93-
94-
async function run () {
95-
// Optional: Check and ensure binary compatibility with current environment
96-
await pty.init()
97-
98-
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash'
91+
import * as os from "node:os";
92+
import * as pty from "@karinjs/node-pty";
93+
94+
async function run() {
95+
const shell = os.platform() === "win32" ? "powershell.exe" : "bash";
9996
const ptyProcess = pty.spawn(shell, [], {
100-
name: 'xterm-color',
97+
name: "xterm-color",
10198
cols: 80,
10299
rows: 30,
103100
cwd: process.env.HOME,
104-
env: process.env
105-
})
101+
env: process.env,
102+
});
106103

107104
ptyProcess.onData((data) => {
108-
process.stdout.write(data)
109-
})
105+
process.stdout.write(data);
106+
});
110107

111-
ptyProcess.write('ls\r')
112-
ptyProcess.resize(100, 40)
113-
ptyProcess.write('ls\r')
108+
ptyProcess.write("ls\r");
109+
ptyProcess.resize(100, 40);
110+
ptyProcess.write("ls\r");
114111
}
115112

116-
run()
113+
run();
117114
```
118-
119-
## API
120-
121-
### Base API
122-
123-
This package supports all original APIs from [@homebridge/node-pty-prebuilt-multiarch](https://github.com/homebridge/node-pty-prebuilt-multiarch).
124-
125-
### Extended API
126-
127-
We've added the following new API on top of the original ones:
128-
129-
#### init()
130-
131-
The `init()` method checks if the prebuilt binary is compatible with the current Node.js/Electron environment. This method is optional and is mainly useful in the following scenarios:
132-
133-
- After switching Node.js or Electron versions, to verify compatibility
134-
- When you need to reinstall binaries compatible with the current environment
135-
136-
> Tip: If you don't want to call the init() method, you can also directly run `npx pty` to reinstall binaries compatible with the current environment.

0 commit comments

Comments
 (0)