iam4x / zsh-iterm-touchbar

Display feedback of terminal in the 🍏 Touchbar
MIT License
689 stars 75 forks source link

tapping [yarn-run] results in an error #20

Closed LeonardFollner closed 6 years ago

LeonardFollner commented 6 years ago

Tapping [yarn-run] results in the following error displayed on the console:

console.log({"type":"error","data":"No command specified."}.data.items.filter(name => !name.includes(':')).sort((a, b) => a.localeCompare(b)).filter((name, idx) => idx < 12).join(' '))
                                                                      ^

TypeError: Cannot read property 'filter' of undefined
    at [eval]:1:71
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.exports.runInThisContext (vm.js:77:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:541:32)
    at bootstrap_node.js:315:29
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I do run export YARN_ENABLED=true in my .zshrc. Using npm-run either displays no scripts or everything works fine. I am running the latest version of zsh, oh-my-zsh, iTerm2 and zsh-iterm-touchbar is freshly cloned to ~/.oh-my-zsh/custom/plugins/

gvlekke commented 6 years ago

looked a little bit into it and in the method _displayYarnScripts this command works:

Object.keys($(npm run --json))

and with yarn it doesnt

Object.keys($(yarn run --json))

so looks likes yarn does something different and because of that this doesn't work :/ workarround for now is that I just replaced the yarn with npm, but the running is still with yarn. So only checks the package.json with npm but it is still executing with yarn.

dapetcu21 commented 6 years ago

I have the same issue. The script apparently pipes yarn run --json through sed '4!d', effectively deleting the first 4 lines, but my yarn run --json output is as follows:

(node:18195) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
{"type":"error","data":"No command specified."}
{"type":"info","data":"Commands available from binary scripts: acorn, ansi-html, atob, babylon, browserslist, cssesc, csso, detect, detect-libc, detect-port, errno, escodegen, esgenerate, eslint, esparse, esvalidate, flow, handlebars, he, html-minifier, import-local-fixture, internal-ip, is-ci, jest, jest-runtime, js-yaml, jsesc, json5, loose-envify, miller-rabin, mime, mkdirp, multicast-dns, needle, node-pre-gyp, nopt, rc, react-scripts, regjsparser, rimraf, sane, semver, sha.js, sshpk-conv, sshpk-sign, sshpk-verify, strip-indent, svgo, sw-precache, uglifyjs, uuid, webpack, webpack-dev-server, which"}
{"type":"info","data":"Project commands"}
{"type":"list","data":{"type":"possibleCommands","items":["build","eject","start","test"],"hints":{"build":"react-scripts build","eject":"react-scripts eject","start":"react-scripts start","test":"react-scripts test --env=jsdom"}}}
{"type":"error","data":"No command specified."}

So the sed yields {"type":"info","data":"Project commands"} instead of the list line.