cherry-pick icon indicating copy to clipboard operation
cherry-pick copied to clipboard

Option to ignore some files

Open diegohaz opened this issue 6 years ago • 6 comments

I'd like to ignore some files by either using some option like --ignore or being able to pass the entire glob pattern to the CLI.

The latter seems to not be possible because of this path.join(inputDir, '!(index).{js,ts}'). https://github.com/Andarist/cherry-pick/blob/c78c2a3d2862e3650ce83021c16e3bc07155df28/lib/index.js#L27

I think it would be better if the library let the user have full control over the glob pattern.

Related to https://github.com/reakit/reakit/issues/106

diegohaz avatar Aug 02 '18 04:08 diegohaz

I thought about enabling glob patterns, that was too complex for MVP version though. Problem was that globs would allow nested files to be caught & it seemed to me that nested proxy directories should be generated for such. It's of course doable, just didn't want to do it from the start until such requirement arise. WDYT? do you want to support things like reakit/components/Arrow?

Andarist avatar Aug 02 '18 07:08 Andarist

I wanted reakit/Arrow.

This is how my es folder looks like after using rollup with experimentalCodeSplitting:

/Users/diegohaz/Projects/reakit/es
├── Arrow.js
├── Backdrop.js
├── Base.js
├── Block.js
├── Blockquote.js
├── Box.js
├── Button.js
├── Card.js
├── Code.js
├── Divider.js
├── Field.js
├── Fit.js
├── Flex.js
├── Grid.js
├── Group.js
├── Heading.js
├── Hidden.js
├── Image.js
├── Inline.js
├── InlineBlock.js
├── InlineFlex.js
├── Input.js
├── Label.js
├── Link.js
├── List.js
├── Navigation.js
├── Overlay.js
├── Paragraph.js
├── Popover.js
├── Shadow.js
├── Sidebar.js
├── Step.js
├── Table.js
├── Tabs.js
├── Tooltip.js
├── as-8a1cd76d.js
├── as.js
├── chunk-0fe09706.js
├── chunk-11ba5b6c.js
├── chunk-292370e2.js
├── chunk-2994402c.js
├── chunk-2d09a12e.js
├── chunk-5c6a1db8.js
├── chunk-6284d51f.js
├── chunk-76e2ba20.js
├── chunk-7d8288bf.js
├── chunk-baa8a0da.js
└── reakit.js

I passed es as input-dir to cherry-pick since it already has a flat structure. It worked well, but I wanted to ignore some files, like those chunks.

But, also, working with glob patterns is awful. I made some changes on cherry-pick and tested it locally, but I couldn't write a glob to proper ignore chunks, reakit.js etc. I'm now creating some specific scripts like the one you show in the article. It seems to be a better solution.

diegohaz avatar Aug 02 '18 07:08 diegohaz

Yeah, I hate globs too - always struggling with them whenever I want to ignore some stuff etc >.<

I'd love to help you with the task - we can introduce a new option to the cherry-pick - maybe smth like files[] that would skip findFiles call entirely and just use what got supplied to it, that way you could call cherry-pick programatically with "purified" list of files instead of relaying on CLI tool.

Andarist avatar Aug 02 '18 08:08 Andarist

That would work

diegohaz avatar Aug 02 '18 08:08 diegohaz

+1

aleclarson avatar May 06 '20 23:05 aleclarson

Happy to accept a PR for this - I won't be able to work on it myself though, I've switched entirely to using http://preconstruct.tools/ which comes with support for multiple entries like defined here (although integrates with Rollup, whereas cherry-pick assumes Babel/TSC-generated directories). It's an excellent tool and I encourage everyone to just use it over any custom setups.

Andarist avatar May 07 '20 07:05 Andarist