Would like to call build from a different directory

Is it possible to call middleman build against a source directory other than the current directory? I would like to pass the root source directory as an argument. I’m attempting to package middleman as an sbt-plugin. For this to work well, I won’t be able to put the shell into the root of the source directory.

I attempted passing the directory as an argument, but that does not appear to be correct:

ERROR: "middleman build" was called with arguments ["mm-project/"]
Usage: "middleman build [options]"

I’ve searched google for middleman build options but that turns up plenty of stuff that I’m not looking for. I apologize in advance for the beginner’s question, and I appreciate the community’s patience.

Thanks,
Joe

I don’t see this documented anywhere, but Middleman allows you to specify the root directory by setting the environment variable MM_ROOT. The source, build, data, etc. directories are defined relative to the root directory and can be overridden in config.rb.

Be mindful of your gem load paths when doing this, as Bundler may not automatically discover the project’s Gemfile.

Also, middleman build --help would be a good substitute for that web search.

1 Like