Making exclude emulate include
See original GitHub issueFor some projects it would be much easier to have an include option rather than exclude. Bigger projects tend to have a lot of files not required at runtime (see dungeon-revealer/dungeon-revealer#1115). This makes it infeasible to explicitly list every pattern to exclude. Here are my attempts to get the exclude option to emulate the include option at maxb2/caxa-exclude-example. N.B. some of these use GNU/Linux tools and aren’t necessarily portable to other OSes.
No excludes
npx caxa -i . -o hello-no-exclude -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/app.js"
Archive contents:
app.js
.git/
node_modules/
package.json
package-lock.json
README.md
Hardcode the excludes
npx caxa -i . -o hello-exclude-names --exclude README.md .git -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/app.js"
app.js
node_modules/
package.json
package-lock.json
Trying to emulate “include”
npx caxa -i . -o hello-exclude-glob --exclude * '!app.js' '!node_modules' '!package*' -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/app.js"
app.js
.git/
node_modules/
package.json
package-lock.json
Bash globbing doesn’t include hidden files!
$ echo *
app.js node_modules package.json package-lock.json README.md
Explicitly exclude hidden files
npx caxa -i . -o hello-exclude-glob-dot --exclude * '\.*' '!app.js' '!node_modules' '!package*' -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/app.js"
app.js
node_modules/
package.json
package-lock.json
Use find
to list the excludes.
EXCLUDE=$(find . -maxdepth 1 -not -path '.' -not -name 'node_modules' -not -name 'app.js' -not -name 'package*' -exec echo {} + | sed -e 's|\./||g') && npx caxa -i . -o hello-exclude-glob-find --exclude $EXCLUDE -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/app.js"
app.js
node_modules/
package.json
package-lock.json
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
👍 I like the idea of having
--include
and--exclude
being mutually exclusive. Let’s have it for caxa@2.1.0.The implementation ended up not being as straightforward as I expected, so I decided to just document how to emulate
--include
with--exclude
. Let’s say that it’s designed after.gitignore
😃 It’s out as part of caxa@2.1.