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

File actions occur relative to the markdown file but command actions occur relative to process.cwd() #40

Open
10hendersonm opened this issue Sep 23, 2022 · 0 comments

Comments

@10hendersonm
Copy link
Member

When running against a file in a different directory, these two inject blocks should be interchangeable. They're not because the command action is being issued within the current working directory, while the file action is being issued relative to the location of the markdown file.

<!-- CODEBLOCK_START { "value": ".nvmrc" } -->
<!-- CODEBLOCK_END -->

<!-- CODEBLOCK_START { "type": "command", "value": "cat .nvmrc" } -->
<!-- CODEBLOCK_END -->

Duplication Steps

mkdir -p nested-dir
echo "Test Root-Level File" > test-root.txt
echo "Test Nested File" > nested-dir/test-nested.txt

echo 'Works:\n<!--CODEBLOCK_START {"value":"cat test-root.txt","type":"command"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Fails:\n<!--CODEBLOCK_START {"value":"test-root.txt"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Works:\n<!--CODEBLOCK_START {"value":"test-nested.txt"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Fails:\n<!--CODEBLOCK_START {"value":"cat test-nested.txt","type":"command"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

I'd probably like if all actions happened relative to the file rather than relative to the cwd.

Dream case:

mkdir -p nested-dir
echo "Test Root-Level File" > test-root.txt
echo "Test Nested File" > nested-dir/test-nested.txt

echo 'Fails:\n<!--CODEBLOCK_START {"value":"cat test-root.txt","type":"command"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Fails:\n<!--CODEBLOCK_START {"value":"test-root.txt"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Works:\n<!--CODEBLOCK_START {"value":"test-nested.txt"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Works:\n<!--CODEBLOCK_START {"value":"cat test-nested.txt","type":"command"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Works:\n<!--CODEBLOCK_START {"value":"../test-root.txt"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a

echo 'Works:\n<!--CODEBLOCK_START {"value":"cat ../test-root.txt","type":"command"}--> <!--CODEBLOCK_END-->' > nested-dir/README.md
npx -y markdown-inject -a
@10hendersonm 10hendersonm changed the title File actions occur relative to the file but command actions occur relative to process.cwd() File actions occur relative to the markdown file but command actions occur relative to process.cwd() Sep 23, 2022
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

1 participant