[go: nahoru, domu]

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

I tried 0.7.3 and the cli doesn't work yet. #317

Closed
Scrum opened this issue Aug 18, 2020 · 4 comments · Fixed by #321
Closed

I tried 0.7.3 and the cli doesn't work yet. #317

Scrum opened this issue Aug 18, 2020 · 4 comments · Fixed by #321
Labels
Milestone

Comments

@Scrum
Copy link
Member
Scrum commented Aug 18, 2020

I tried 0.7.3 and the cli doesn't work yet. Here is how I use it:

posthtml "some/inputFolder/**/*.html" "!**/some/outFolder/**" -r some/inputFolder -a -o some/outFolder

(notice the glob patterns are quoted so that the shell doesn't expand them).

In order for fast-glob to grab those files you shouldn't resolve the path to absolute - you should remove the following line

.map(file => path.join(path.resolve(root), file));

Originally posted by @giuseppeg in #313 (comment)

@Scrum Scrum modified the milestones: 0.7.4, 0.7.5 Aug 18, 2020
@Scrum
Copy link
Member Author
Scrum commented Aug 19, 2020

@giuseppeg Hello,

(notice the glob patterns are quoted so that the shell doesn't expand them).

The use of quotes is due to the fact that when using a pattern like *, the nodejs tries to resolve this by returning all the file matches from the process.cwd.

test.js

console.log(process.argv.slice(2));

you terminal

$ node test.js *

Such a script will work correctly.

node lib/cli.js "fixtures/**/*.html" -r test -a -o outFolder

In order for fast-glob to grab those files you shouldn't resolve the path to absolute - you should remove the following line

fast-glob works correctly, the problem lies in "!**/some/outFolder/**" and I'm trying to understand her

node lib/cli.js "fixtures/**/*.html" "!input-nesting" -r test -o outFolder  

transform to

node lib/cli.js "fixtures/**/*.html" "nesting" -r test -o outFolder

and try execute

zsh: event not found: input

As expected, it was all about shielding ! and of course, if you run the command as an npm script, then no escaping for ! is required
you terminal

node lib/cli.js "**/*.html" "\!input-nesting" -r test/fixtures -o outFolder  

you package.json

"build-one": "node lib/cli.js '**/*.html' !input-nesting -r test/fixtures -o outFolder",
"build-two": "node lib/cli.js '**/*.html' !**/one-io -r test/fixtures -o outFolder"

@Scrum Scrum added the bug label Aug 19, 2020
Scrum added a commit that referenced this issue Aug 19, 2020
@Scrum Scrum linked a pull request Aug 19, 2020 that will close this issue
@giuseppeg
Copy link
Contributor
giuseppeg commented Aug 19, 2020

@Scrum I use bash instead of zsh and the CLI received the pattern just fine.

When quoted, "!**/some/outFolder/**" it is just a string and the shell won't expand it.

Then fast-glob will use the CLI args and find or exclude files just fine - that was the case with an older version of posthtml-cli before you changed it to resolve them to absolute paths.

What was the reason to prefix the patters with the absolute path?

@Scrum
Copy link
Member Author
Scrum commented Aug 20, 2020

What was the reason to prefix the patters with the absolute path?

For a correct resolution relative to the root directory

@giuseppeg
Copy link
Contributor

ah ok! I was indeed doing this in my own script and that messed things up

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

Successfully merging a pull request may close this issue.

2 participants