Code Monkey home page Code Monkey logo

Comments (3)

nfischer avatar nfischer commented on June 11, 2024

Seems like a reasonable feature request. We could do the same for shell.mv() and shell.rm() too.

It looks like we already have something like this for shell.chmod(), where the behavior is simply console.log() each line. So this output would not be part of the .stdout string returned by the function. Does printing directly the console work for your use case, or do you need the output stored in .stdout for programmatic access?

shelljs/src/chmod.js

Lines 192 to 194 in f7a7c75

if (options.verbose) {
console.log(file + ' -> ' + newPerms.toString(8));
}

from shelljs.

nicky1038 avatar nicky1038 commented on June 11, 2024

@nfischer Thank you for such a fast response and your willingness to help!

My goal is just to print this information into the console. Still, doesn't console.log invoke process.stdout.write under the hood? If so, then there would be no flaws in its usage

from shelljs.

nfischer avatar nfischer commented on June 11, 2024

Sorry, I think I was unclear. You're correct that console.log() prints to the "real" stdout. What I was talking about in my last comment is the ShellString return type, which has object properties named .stdout, .stderr, and .code: https://github.com/shelljs/shelljs#shellstringstr. We typically aim for ShellJS functions to return a string in the .stdout property which represents whatever the real Unix command would have printed to stdout (e.g., if Unix cat prints a file's contents to stdout, then shell.cat() returns a file's contents as a ShellString).

But if you don't need programmatic access to the output, then I think it's fine to just print directly to console like you've done in #1129.

from shelljs.

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.