Skip to content
项目

关于

PTY for Node through Rust FFI

开发工具

这些数字如何统计

实测星标增长

24小时
正在收集历史
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

@replit/ruspty - PTY for JavaScript through Rust FFI

A very thin wrapper around PTYs and processes.

const { Pty } = require('@replit/ruspty');

const pty = new Pty({
  command: '/bin/sh',
  args: [],
  envs: {},
  size: { rows: 24, cols: 80 },
  onExit: (...result) => {
    // TODO: Handle process exit.
  },
});

const read = pty.read;
const write = pty.write;

read.on('data', (chunk) => {
  // TODO: Handle data.
});
write.write('echo hello\n');

Sandboxing a process without a PTY

On Linux x64, the platform package also ships ruspty-sandbox, which runs a command under the same rules as the sandbox option of Pty, for supervisors that start processes themselves:

const { getSandboxBinaryPath } = require('@replit/ruspty');

spawn(getSandboxBinaryPath(), [
  '--rules',
  JSON.stringify([
    {
      operation: 'Modify',
      prefixes: ['/repo/.git/'],
      message: 'Writing to .git is not allowed.',
    },
  ]),
  '--',
  'npm',
  'run',
  'build',
]);

It uses no PTY and joins no cgroup: stdio is inherited, the command's exit status becomes its own, and a rule violation prints the rule's message to stderr and exits with 254. Build it locally with npm run build:sandbox.

Local Development

  • npm install
  • npm run build
  • npm run test

Publishing

Following "Publish It" section from napi-rs docs:

  1. git clean -f && npm install && npm run build
  2. npm version [major|minor|patch]
  3. Send that as a Pull Request to GitHub. Ensure that the commit message consisting only of x.y.z - this is how the CI decides to publish to npm!

Configure npm trusted publishing for replit/ruspty with the workflow filename CI.yml before merging a version bump PR. The publish job now uses GitHub OIDC, so NPM_TOKEN is no longer required.

探索相关项目

加载中…