Giter Club home page Giter Club logo

node-spinner's Introduction

node-spinner

A simple spinner for node cli.

NPM NPM


Installation

This package is available on npm as cli-spinner.

npm install cli-spinner

Example usage

var Spinner = require('cli-spinner').Spinner;

var spinner = new Spinner('processing.. %s');
spinner.setSpinnerString('|/-\\');
spinner.start();

APIs

var obj = new Spinner('processing.. %s')

var obj = new Spinner({
    text: 'processing.. %s',
    stream: process.stderr,
    onTick: function(msg){
        this.clearLine(this.stream);
        this.stream.write(msg);
    }
})

Create a new spinner object. The advanced options can be used in any combination, none of them are required.

obj.start()

Starts the spinner.

obj.stop(clean)

Stops the spinner. Accepts a Boolean parameter to clean the console.

obj.isSpinning()

Returns true/false depending on whether the spinner is currently spinning.

obj.setSpinnerString(spinnerString)

Sets the spinner string. Accepts either a String or an Integer index to reference the built-in spinners.

obj.setSpinnerDelay(spinnerDelay)

Sets the spinner animation speed.

obj.setSpinnerTitle(spinnerTitle)

Sets the spinner title. Use printf-style strings to position the spinner.

Spinner.setDefaultSpinnerString(spinnerString)

Sets the default spinner string for all newly created instances. Accepts either a String or an Integer index to reference the built-in spinners.

Spinner.setDefaultSpinnerDelay(spinnerDelay)

Sets the default spinner delay for all newly created instances.

Demo

To see a demonstration of the built-in spinners, point your console at the example folder and run:

node spinner.js

See list of spinners here

preview

node-spinner's People

Contributors

b3by avatar bojack-corgi avatar brutalchrist avatar bryant1410 avatar brycekahle avatar helloiampau avatar janslow avatar nnnnathann avatar pierrefourgeaud avatar piranna avatar rickycodes avatar shennan avatar sixcircuit avatar w1ndy avatar ythecombinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

node-spinner's Issues

Can't terminate a process

When running a process with a spinner, when interruptering (cmd + c) the spinner doesn't stop and forces continual execution

Not clear when execute a new console.log

With this code:

spinner.start();
console.log('Foo')

The result is:

/ Foo
"spinner this"

Ever new console.log, some part of spinner continue in terminal, how I solve this !!

thx

Use current position instead of creating newline

This is a great library, thanks for it!

Is it possible to show the spinner and title in the current cursor position rather than bumping it down to a new line? I have an instance where I have some text already outputted in the line with process.stdout.write, and when I start the spinner, it moves to a new line. Can I prevent this or is it not currently possible?

Animation stops when shelljs.exec or consolo.log is called

I want to use the spinner so the user knows something is loading, but in the case of a shell command the animation just freezes and that makes it useless in some of my usecases.
Is there a workaround or am I missing anything?
Creating a childprocess and executing the command there doesnt help, as well as executing it in silent mode.

spinner.start()
shelljs.exec(my command that takes some seconds)
spinner.stop(true)

thanks already

Spinner not appearing until stop called

I'm having a flush error it seems -- the spinner doesn't show up until done is called. I'm calling start outside a promise and stop inside a promise for context.

Best,
Jon

No lock file found in the clispinner project on Tag: v0.2.10

Issue: There is no package-lock.json or npm-shrinkwrap.json file uploaded to the GitHub repository https://github.com/helloIAmPau/node-spinner

Questions: We are conducting a research study on the lock files used in JS projects. We were curious:

  1. Will you upload any lock files to GitHub as recommended above? (Yes/No), and why?:
  2. Do you have any additional comments? (If so, please write it down):

For any publication or research report based on this study, we will share all responses from developers in an anonymous way. Both your projects and personal information will be kept confidential.

Rationale: NPM introduced package-lock.json and npm-shrimpwrap.json files to capture the exact dependency tree installed at any point in time. When package.json defines the required dependencies and their respective versions using semantic versioning (e.g., β€œexpress”: β€œ^4.16.4”), npm always downloads the latest version of packages to satisfy the specified version ranges (e.g., 4.17.1)[1]. If the latest version of any package keeps changing and has backward incompatibility issues with previous versions, the project may have an inconsistent running environment and get intermittent failures. In such scenarios, it can be very difficult for developers to debug programs and settle down the software environment [2].

List of Risks:

  • Nondeterministic package downloads and installations across different environments [3]
  • Produce irreproducible builds [4]
  • Inconsistent results of program execution [5]

Suggested Solution: Please fixate the dependencies by either specifying the exact library version in the package.json file or by uploading the package-lock.json or npm-shrinkwrap.json file to GitHub.

References:
https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json
https://blog.logrocket.com/why-you-should-use-package-lock-json/
2019. 10 npm Security Best Practices. https://snyk.io/blog/ten-npm-security-best-practices/.
Pronnoy Goswami, Saksham Gupta, Zhiyuan Li, Na Meng, and Daphne Yao. 2020. Investigating The Reproducibility of NPM Packages. In2020 IEEE International
2021. Npm Security Best Practices. https://bytesafe.dev/posts/npm-security-best-practices/#no9-deterministic-results.

NPM source is different than Github source.

Any reason as to why the code that we get from npm is different than the source found here? If this was a larger library I'd say that's quite misleading as it could contain malicious code that's not easily found.

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.