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

feat: allow globbing #23

Closed
wants to merge 1 commit into from
Closed

feat: allow globbing #23

wants to merge 1 commit into from

Conversation

filipesilva
Copy link
Contributor

Close #21

Globbing files

$ clang-format --glob=folder/**/*.js

This will run clang-format once per file result, and show the total formatted files at the end.

@alexeagle alexeagle self-assigned this Feb 12, 2016

$ clang-format --glob=folder/**/*.js

This will run `clang-format` once per file result, and show the total
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to document what the globbing semantics are. It's sufficient to point to the docs for the glob library we use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger, will add this.

@filipesilva
Copy link
Contributor Author

Added link to glob semantics, chunking files in sets of 30, added serial execution of spawned processes.

@@ -6,6 +6,8 @@ var os = require('os');
var path = require('path');
var resolve = require('resolve').sync;
var spawn = require('child_process').spawn;
var glob = require("glob");
var async = require("async");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a funny name for it now. Is the library worth having the dependency now, rather than just a for loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the operation itself (spawning a child process and waiting for it to end) is still async so a simple for loop wouldn't work.

I could replicate async's series functionality with a well crafted recursive function, but async does it better and is more well tested so it seemed a better fit for this wrapper.

@alexeagle
Copy link
Contributor

LGTM
Do you need a merge/release? maybe you don't have permissions

@filipesilva
Copy link
Contributor Author

Index 0 matching is in. But something seems breaking in the tests... give me a sec.

@filipesilva
Copy link
Contributor Author

Nvm, was just running the wrong tests. It's good to go.

I don't have permissions, no. Could you perhaps do it?

@alexeagle
Copy link
Contributor

Merged in cfd69a8 - thanks!!!

@alexeagle alexeagle closed this Feb 13, 2016
@filipesilva
Copy link
Contributor Author

Sweet.


This will run `clang-format` once per file result, and show the total
formatted files at the end.
See [node-glob](https://github.com/isaacs/node-glob) for globbing semantics.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that we don't afford a way to pass options - I was just trying to write up an example and need exclude...

@mprobst
Copy link
Contributor

mprobst commented Feb 15, 2016

Could you add docs that this is of course a Windows-only issue, and that on UNIXens including Macs the shell itself is doing the globbing?

To that point, I think it might be smarter to not have --glob=...., but rather just check if the machine is running on Windows, and then glob over the regular arguments. That'd allow users to run mostly the same command line on Linux, Macs, and Windows, which is nice for consistent development environments.

@alexeagle
Copy link
Contributor

The use case I have for this is in package.json

"scripts": {
  "format": "clang-format --glob **/*.ts"
}

This command needs to be cross-platform, and I don't want to use only the shell (can't get recursive globs without some platform dependent helper)

@filipesilva
Copy link
Contributor Author

@alexeagle can you check if these proposal fits your needs? #25 (comment) (including @mprobst comment, that you probably have to expand the ... to see).

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 this pull request may close these issues.

4 participants