Lack of interest build.json exclude_files and exclude_directories directives

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

Sim

Well-known member
It would be really useful to have some extra build.json directives to allow us to selectively exclude additional files and directories from the build process.

Specifically - I am building some unit tests for my addon using phpunit, but those files don't need to be distributed - so I would like to exclude phpunit.xml and my tests directory from the build process.
 
Upvote 4
This suggestion has been closed. Votes are no longer accepted.
Essentially this is what the exec portion of the build.json is for. We actually stopped ourselves from implementing an explicit option because it can just be done with exec.

The commands are run relative to the _build directory IIRC so you’d just add a couple of exec commands to rm the files or rm -rf the directories you don’t want in the final zip.
 
Essentially this is what the exec portion of the build.json is for. We actually stopped ourselves from implementing an explicit option because it can just be done with exec.

The commands are run relative to the _build directory IIRC so you’d just add a couple of exec commands to rm the files or rm -rf the directories you don’t want in the final zip.

Thanks @Chris D - I'll give that a go.
 
I'd prefer the tests to be included, this way everyone can verify that the tests do pass :)

I generally make my addon code available via Bitbucket - people who want to run their own unit tests can clone the repository and get the unit tests that way.
 
Git for Windows should provide cross-platform compatibility for the main Bash commands by default.

Certainly of the commands for this use case, they should work without issue on Windows if you have Git installed with the default options.

That even extends to / working as a directory separator instead of backslash.

So an exec command of "rm -rf some/relative/path" should work fine.

That’s assuming it is available when running through exec type commands in PHP on Windows, but I believe it is.
 
Git for Windows should provide cross-platform compatibility for the main Bash commands by default.
I just updated my Git For Windows version, and the default configuration for Git For Windows is to associate .sh files with bash, but not to inject linux utilities (like rm) into Windows PATH.

1538539194198.webp

1538539527671.webp
 
Last edited:
I just updated my Git For Windows version, and the default configuration for Git For Windows is to associate .sh files with bash, but not to inject linux utilities (like rm) into Windows PATH.

View attachment 184630

View attachment 184631

I run PhpStorm and Atlassian Sourcetree Git client on Windows - but my actual dev server is running on Ubuntu via VMware (so I can develop in a similar environment to my production servers).

There are other virtual machines you can use to run a dev server (Vagrant? Scotchbox?) - I recommend seeing if you can migrate to using a Linux based dev environment to avoid these OS based issues.

Alternatively - investigate running the WIndows Subsystem for Linux natively on Windows 10 - I haven't tried it myself, but I've heard really good things about it (it's real Linux really running natively on Windows, not emulated - MS have done a lot of good work here!).
 
Ahh I could have sworn it was default but was forgetting it overwrites some default commands.

Honestly though, it’s likely very much so worth having and doesn’t require the Linux subsystem (which I’ve never used in great detail but it’s likely overkill for just alising a few commands).
 
Essentially this is what the exec portion of the build.json is for. We actually stopped ourselves from implementing an explicit option because it can just be done with exec.

The commands are run relative to the _build directory IIRC so you’d just add a couple of exec commands to rm the files or rm -rf the directories you don’t want in the final zip.

Just to confirm, I added the following to my build.json file and it worked exactly as advertised:

JSON:
{
    "exec": [
        "rm -v _build/upload/src/addons/{addon_id}/phpunit.xml",
        "rm -v -r _build/upload/src/addons/{addon_id}/tests"
    ]
}

... no phpunit.xml or tests folder included in release zip file (y)

Note that I also include the following command in build.json to remove the unit testing code (phpunit and mockery) from the vendor folder and to optimise the autoloader for production use:

"composer install --working-dir=_build/upload/src/addons/{addon_id}/ --no-dev --optimize-autoloader",

I should write a tutorial on how to do unit testing in XF :unsure:
 
Back
Top Bottom