madhur / PortableJekyll

Portable Jekyll for Windows
http://www.madhur.co.in/blog/2013/07/20/buildportablejekyll.html
382 stars 98 forks source link

Add ability to pass commands to Portable Jekyll #25

Open christianspecht opened 8 years ago

christianspecht commented 8 years ago

With this change, you can still use setpath.cmd to open a command prompt and enter Jekyll commands, like before.

Plus, you can now pass a command which will be executed.
This is useful to create batch files which you can simply double-click to execute something via Portable Jekyll:

1. Building your project with the Jekyll version from Portable Jekyll

Create a batch file in your project's folder with the following content:

"c:\PathToPortableJekyll\setpath.cmd" "jekyll serve"

Executing this batch file will use the Portable Jekyll version in the specified path to build/serve your project.

I often use batch files to run Jekyll when I need to supply additional configuration settings and I'm too lazy to type jekyll serve --foo bar --baz xyz by hand each time.

2. Executing a Ruby script using the Ruby version from Portable Jekyll

call "c:\PathToPortableJekyll\setpath.cmd" "ruby c:\foo\somescript.rb"

A batch file with this content will terminate after execution (cmd /k won't), so I can call it from another batch file.
(my use case: I have an existing batch file backing up stuff from my machine, and I needed to run wunderlist-backup from it, so my Wunderlist data is included in the backup)