petersalomonsen / wasm-git

GIT for nodejs and the browser using https://libgit2.org compiled to WebAssembly with https://emscripten.org
Other
649 stars 37 forks source link

Recommend pratice for getting git message? #80

Closed ngdangtu-vn closed 1 year ago

ngdangtu-vn commented 1 year ago

For instance, when I run git status, it would only display message in console.log(). I would like to receive the message and display it in the frontend website. For now, I have to do this trick: https://stackoverflow.com/a/52142526

However, if the website has more than 1 lib and they all spill everything to console.log than it will be very trouble to filter them.

Do we have better ways for this case?

ngdangtu-vn commented 1 year ago

I think I found a better way:

// worker.js
self.Module = {}

self.Module.print = content => postMessage({ type: 'msg', content })
self.Module.printErr = content => postMessage({ type: 'err', content })

Source: https://emscripten.org/docs/api_reference/module.html#id1