Skip to content
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

Relative paths for wavedrom-cli #45

Open
bradleyharden opened this issue May 26, 2022 · 2 comments
Open

Relative paths for wavedrom-cli #45

bradleyharden opened this issue May 26, 2022 · 2 comments

Comments

@bradleyharden
Copy link

I don't normally install Node or NPM on my machines. I didn't want to install it purely for wavedrom-cli, so I tried to use a Docker container. I was able to pull a Node container and install wavedrom-cli within it. Then I created a little wrapper script to use the container as if it were an executable. With that approach, I was able to produce SVGs at the command line.

Unfortunately, I was not able to use it with this plugin. The problem is one of absolute vs. relative paths. Because I have to mount a host directory into the container, I need to know the relative path to the input file, not the absolute path. Yet the current implementation uses an absolute path.

Would you consider making these paths relative? Do you think it could break anything?

For the moment, I'm using realpath --relative-to="$PWD" in my wrapper script. It works, but it's not the most robust solution. I thought I would at least ask to see if there might be a better approach.

@bavovanachte
Copy link
Owner

bavovanachte commented May 27, 2022

Hi!

I don't normally install Node or NPM on my machines.

I don't think you're the only one, so I think it's worth supporting it somehow. I'd be hesitant to just flip the switch on this entirely, but I think we can add an option for it.

Is your approach similar to this one? https://github.com/mvonbun/docker-wavedrom-cli. I'm asking cause I'd like to reproduce the issue and add a link in the readme, as this will likely help others as well.

@bradleyharden
Copy link
Author

@bavovanachte, sorry for the delay.

I think my approach is a bit simpler than the one you linked, but I'm not terribly familiar with the NPM ecosystem, so I don't know how they compare.

Here is my Dockerfile:

FROM docker.io/library/node:12.0

RUN npm -g config set user root \
 && npm i wavedrom-cli -g

ENTRYPOINT ["wavedrom-cli"]

And here is my wrapper script:

#!/bin/bash

args=("$@")
for i in "${!args[@]}"; do
  if [[ "${args[$i]}" = /* ]]; then
    args[$i]=$(realpath --relative-to="$PWD" "${args[$i]}")
  fi
done
podman run --rm -v "$PWD":/wavedrom -w /wavedrom localhost/wavedrom-cli ${args[@]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants