Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oclif/table

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/table - npm Package Compare versions

Comparing version 0.1.23 to 0.1.24

52

lib/table.js
/* eslint-disable react/prop-types */
import cliTruncate from 'cli-truncate';
import { Box, Text, render } from 'ink';
import { WriteStream } from 'node:tty';
import { EventEmitter } from 'node:events';
import { sha1 } from 'object-hash';

@@ -282,8 +282,12 @@ import React from 'react';

/**
* A custom WriteStream that captures the frames written to stdout.
* Return a custom WriteStream that captures the frames written to stdout.
* This allows us to avoid an issue where Ink rerenders the component twice
* because it uses ansiEscapes.clearTerminal, which doesn't seem to have
* the desired effect in powershell.
*
* Implementation inspired by https://github.com/vadimdemedes/ink/blob/master/test/helpers/create-stdout.ts
*/
class Stream extends WriteStream {
const createStdout = () => {
// eslint-disable-next-line unicorn/prefer-event-target
const stdout = new EventEmitter();
// Override the rows so that ink doesn't clear the entire terminal when

@@ -294,34 +298,24 @@ // unmounting the component and the height of the output is greater than

// This might be a bad idea but it works.
rows = 10_000;
frames = [];
lastFrame() {
return this.frames
.filter((f) => {
const stripped = stripAnsi(f);
return stripped !== '' && stripped !== '\n';
})
.at(-1);
}
write(data) {
this.frames.push(data);
stdout.rows = 10_000;
stdout.columns = process.stdout.columns ?? 80;
const frames = [];
stdout.write = (data) => {
frames.push(data);
return true;
}
}
};
stdout.lastFrame = () => frames
.filter((f) => {
const stripped = stripAnsi(f);
return stripped !== '' && stripped !== '\n';
})
.at(-1);
return stdout;
};
class Output {
stream;
constructor() {
// Use process.stdout if NODE_ENV is `test` OR if tests are being run by wireit on windows (windows + tests run by wireit
// are problematic for an unknown reason)
this.stream =
(process.platform === 'win32' && process.env.npm_lifecycle_script === 'wireit') || process.env.NODE_ENV === 'test'
? process.stdout
: new Stream(process.env.OCLIF_TABLE_FD ? Number(process.env.OCLIF_TABLE_FD) : 0);
this.stream = createStdout();
}
maybePrintLastFrame() {
if (this.stream instanceof Stream) {
process.stdout.write(`${this.stream.lastFrame()}`);
}
else {
process.stdout.write('\n');
}
process.stdout.write(`${this.stream.lastFrame()}\n`);
}

@@ -328,0 +322,0 @@ }

{
"name": "@oclif/table",
"description": "Display table in terminal",
"version": "0.1.23",
"version": "0.1.24",
"author": "Salesforce",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/table/issues",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc