Git Product home page Git Product logo

Comments (6)

casey avatar casey commented on July 20, 2024

Actually, I'm not entirely certain this is so useful. I was able to relatively cleanly add testing to my own project, so I don't have a strong use case for it. Other projects that use atty might be structured differently and thus benefit from the ability to mock atty, but not mine.

from atty.

softprops avatar softprops commented on July 20, 2024

Nice. I'll leave this open in case you need it. Also neat project!

from atty.

hayd avatar hayd commented on July 20, 2024

@casey how did you do this in just?

This might also be useful for #15.

from atty.

casey avatar casey commented on July 20, 2024

Hmm, it's been a while since I wrote the tests. I think that I had an option to force color, regardless of if we were printing to a terminal, so if I wanted to test formatting I could set that option to be true.

from atty.

hayd avatar hayd commented on July 20, 2024

We have something like:

fn permission_prompt(message: String) -> DenoResult<()> {
  if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) { return Err(permission_denied()) };
  eprint!("{} Grant? yN", message);
  ...  // more stuff

What maybe you'd want to do is refactor to use dependency injection instead? https://stackoverflow.com/a/28370712/1240268 but then you not able to get an atty::Stream.

from atty.

hayd avatar hayd commented on July 20, 2024

Okay, here's one way to fake TTYs in stdin, stdout and stderr:
https://stackoverflow.com/a/52954716/1240268
https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e

from atty.

Related Issues (20)

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.