Giter Site home page Giter Site logo

shelljs-plugin-inspect's Introduction

shelljs-plugin-inspect

GitHub Actions npm shelljs-plugin

A ShellJS plugin to add custom REPL inspection for ShellJS output. This turns hard-to-read ShellString objects into nicely formatted text (resembling what the actual unix commands would output).

Installation

$ npm install --save shelljs
$ npm install --save shelljs-plugin-inspect

Tip: If you want to use this plugin (and more REPL goodies), check out my project n_shell to get a REPL with ShellJS loaded by default!

Usage

Here's what ShellJS looks like by default in the REPL:

> // Before this plugin: hard-to-read ShellString objects
> shell.cat('file1.txt');
{ [String: 'These are the file contents\nAnd they\'re printed out nicely!\n']
  stdout:'These are the file contents\nAnd they\'re printed out nicely!\n',
  stderr: null,
  code: 0,
  cat: [Function: bound ],
  head: [Function: bound ],
  tail: [Function: bound ],
  to: [Function: bound ],
  toEnd: [Function: bound ],
  sed: [Function: bound ],
  sort: [Function: bound ],
  uniq: [Function: bound ],
  grep: [Function: bound ],
  exec: [Function: bound ] }

After:

> // After this plugin: nicely formatted text!
> require('shelljs-plugin-inspect');
> shell.cat('file.txt');
These are the file contents
And they're printed out nicely!

> shell.ls();
file.txt
otherfile.txt
...

> shell.pwd();
path/to/current/directory

Writing ShellJS plugins

If you're interested in taking a look at the current state of the ShellJS plugin API, take a look at index.js. This has helpful comments explaining the necessary boilerplate for writing a plugin. For an example usage of the plugin, take a look at test/test.js.

shelljs-plugin-inspect's People

Contributors

dependabot[bot] avatar nfischer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shelljs-plugin-inspect's Issues

Lint broken on node v4

Node version (or tell us if you're using electron or some other framework)

v4

ShellJS version (the most recent version/GitHub branch you see the bug on)

happening on GitHub Actions CI

Operating system

all

Description of the bug:

/home/runner/work/shelljs-plugin-inspect/shelljs-plugin-inspect/node_modules/eslint/node_modules/optionator/node_modules/word-wrap/index.js:9
  let lastCharPos = str.length - 1;
  ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:[37](https://github.com/nfischer/shelljs-plugin-inspect/actions/runs/7124852567/job/19399775022?pr=24#step:5:38)3:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/runner/work/shelljs-plugin-inspect/shelljs-plugin-inspect/node_modules/eslint/node_modules/optionator/lib/help.js:6:14)
    at Object.<anonymous> (/home/runner/work/shelljs-plugin-inspect/shelljs-plugin-inspect/node_modules/eslint/node_modules/optionator/lib/help.js:260:4)
    at Module._compile (module.js:[40](https://github.com/nfischer/shelljs-plugin-inspect/actions/runs/7124852567/job/19399775022?pr=24#step:5:41)9:26)

https://github.com/nfischer/shelljs-plugin-inspect/actions/runs/7124852567/job/19399775022?pr=24

It looks like one of our dependencies is no longer v4-compatible.

Example ShellJS command to reproduce the error:

npm run lint

Make ls output respond to width of terminal

We can improve ls().inspect() by making it format output like:

$ ls
file1.txt   file2.txt   file3.txt

Instead of putting newlines between all of them. Output would break on word boundaries once the entire column-width is taken up. Cash has an implementation of this in its ls command.

Improve the README

Filing a bug so I don't forget.

It'd be a bit better to reformat the README to make it more readable. This would also be really cool to do once ls #1 is solved, since I can show that off.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.