mirror of
https://github.com/zhigang1992/esbuild.git
synced 2026-04-30 10:22:49 +08:00
use the higher-level "IoctlGetWinsize" in logger
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
* Fix compile error due to missing `unix.SYS_IOCTL` in the latest `golang.org/x/sys` ([#396](https://github.com/evanw/esbuild/pull/396))
|
||||
|
||||
The `unix.SYS_IOCTL` export was apparently removed from `golang.org/x/sys` recently, which affected code in esbuild that gets the width of the terminal. This code now uses another method of getting the terminal width. The fix was contributed by [@akayj](https://github.com/akayj).
|
||||
|
||||
## 0.7.2
|
||||
|
||||
* Transform arrow functions to function expressions with `--target=es5` ([#182](https://github.com/evanw/esbuild/issues/182) and [#297](https://github.com/evanw/esbuild/issues/297))
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
ESBUILD_VERSION = $(shell cat version.txt)
|
||||
|
||||
esbuild: cmd/esbuild/*.go pkg/*/*.go internal/*/*.go
|
||||
esbuild: cmd/esbuild/*.go pkg/*/*.go internal/*/*.go go.mod
|
||||
go build "-ldflags=-s -w" ./cmd/esbuild
|
||||
|
||||
npm/esbuild-wasm/esbuild.wasm: cmd/esbuild/*.go pkg/*/*.go internal/*/*.go
|
||||
|
||||
@@ -4,21 +4,12 @@ package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const SupportsColorEscapes = true
|
||||
|
||||
type winsize struct {
|
||||
ws_row uint16
|
||||
ws_col uint16
|
||||
ws_xpixel uint16
|
||||
ws_ypixel uint16
|
||||
}
|
||||
|
||||
func GetTerminalInfo(file *os.File) (info TerminalInfo) {
|
||||
fd := file.Fd()
|
||||
|
||||
@@ -28,9 +19,8 @@ func GetTerminalInfo(file *os.File) (info TerminalInfo) {
|
||||
info.UseColorEscapes = true
|
||||
|
||||
// Get the width of the window
|
||||
w := new(winsize)
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(w))); err == 0 {
|
||||
info.Width = int(w.ws_col)
|
||||
if w, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ); err == nil {
|
||||
info.Width = int(w.Col)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,12 @@ package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const SupportsColorEscapes = true
|
||||
|
||||
type winsize struct {
|
||||
ws_row uint16
|
||||
ws_col uint16
|
||||
ws_xpixel uint16
|
||||
ws_ypixel uint16
|
||||
}
|
||||
|
||||
func GetTerminalInfo(file *os.File) (info TerminalInfo) {
|
||||
fd := file.Fd()
|
||||
|
||||
@@ -27,9 +19,8 @@ func GetTerminalInfo(file *os.File) (info TerminalInfo) {
|
||||
info.UseColorEscapes = true
|
||||
|
||||
// Get the width of the window
|
||||
w := new(winsize)
|
||||
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, unix.TIOCGWINSZ, uintptr(unsafe.Pointer(w))); err == 0 {
|
||||
info.Width = int(w.ws_col)
|
||||
if w, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ); err == nil {
|
||||
info.Width = int(w.Col)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user