pvdz / tenko

An 100% spec compliant ES2021 JavaScript parser written in JS

Home Page:https://pvdz.github.io/tenko/repl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

realpath: command not found

aladdin-add opened this issue · comments

➜  tenko git:(master) ✗ ./t
./t: line 8: realpath: command not found
usage: dirname path
./tests/t.sh: line 6: realpath: command not found
usage: dirname path
./tests/t.sh: line 258: syntax error near unexpected token `;'

os: macos 11.2 Beta (20D5029f)

There appears to be no equivalent of realpath on macos, beyond brew installing coreutils (see https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x).

The only reason I use this is to get the actual folder of the current script, to make sure all commands can be safely executed assuming being in the correct folder. Do you have a better proposal that works on both mac and linux?

From t.sh:

# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
# https://stackoverflow.com/questions/7665/how-to-resolve-symbolic-links-in-a-shell-script
# Move to the folder where this script lives (should be `**/tenko/tests/t.sh`)
cd "$( dirname $(realpath "${BASH_SOURCE[0]}") )" >/dev/null 2>&1

What about node -p 'fs.realpathSync("...")' ?

Considering we're gonna use node anyways, that makes sense. Bit of a chicken egg problem in terms of which node binary to use here. Maybe not very relevant for this particular case.

Lemme know if this fix isn't sufficient. Thanks :) 💚

it seems realpath is also used in ./t

tenko/t

Line 8 in a066b4a

cd "$( dirname $(realpath "${BASH_SOURCE[0]}") )" >/dev/null 2>&1

and, after fixing it, there was a new error:

➜  tenko git:(master) ✗ ./t --help
./tests/t.sh: line 259: syntax error near unexpected token `;'

Eliminated the other use of realpath as well.

I'm not sure what line it's throwing over. Is it not liking this bit?

    c8);&
    coverage):

Cause I'm not sure what the clean alternative is here.

image

I also did test on my ubuntu, it's working fine.