-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modules: add tty #675
base: main
Are you sure you want to change the base?
modules: add tty #675
Conversation
@ahaoboy tests are failing because you need to mark it as external in esbuild config inside |
tests/unit/tty.test.ts
Outdated
describe("tty", () => { | ||
it("isatty", () => { | ||
// FIXME: in the test environment, isatty is always false | ||
expect([ | ||
isatty(1), | ||
isatty(2), | ||
isatty(3), | ||
isatty(4), | ||
]).toEqual([ | ||
false, | ||
false, | ||
false, | ||
false, | ||
]); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I get the same results if I run it on the laptop at hand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The results of running the command line are correct. I suspect that llrt test uses redirection or other unknown behaviors, which causes all false to be returned in the test.
import { isatty } from 'tty'
console.log(
isatty(1),
isatty(2),
isatty(3),
isatty(4),
)
llrt ./a.js
true true false false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that would probably be the case. This is a little troubling because I always run the test suite on the laptop at hand to make sure it is error free before shipping...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now only the return value type is checked
Description of changes
Add tty module and use libc to implement tty.isatty function
Checklist
tests/unit
and/or in Rust for my feature if neededmake fix
to format JS and apply Clippy auto fixesmake check
types/
directoryBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.