Uses shell scripts to render content or batch tasks
CoffeeScript Shell
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitattributes
.gitignore
.npmignore
.travis.yml
Cakefile
Contributing.md
History.md
LICENSE.md
README.md
package.json

README.md

Cmds Plugin for DocPad

Build Status NPM version Dependency Status Gittip donate button Analytics

Convention: .bash Convention: .sh Convention: .ps1 or .cmd (windows only)

The above can be rendered to any extension i.e. (.html.sh) or just run as a single extension process like a script.

.bash and .sh files are supported on windows if you have gnu\bash\sh\cygwyn tools installed and in the environment path.

Scripts can determined when to run, i.e. writeAfter or generateBefore etc...

##Example usage

echo 123
echo 456
echo "<script>"
echo "document.write("
curl http://www.servicestack.net/ServiceStack.Northwind/customers?format=json
echo ".Customers.length);"
echo "</script>"

Windows cmd multiple lines

echo 123 & echo 456

##Front matter options

Name Desc
print true or false. Specifies if you want to print output to the console
when used when wanting to run the script during a specific docpad event
(only works for scripts placed in the shell collection folder)
  • generateBefore
  • generateAfter
  • renderBefore
  • renderAfter
  • writeBefore
  • writeAfter
  • render (default)

Install

npm install --save docpad-plugin-cmds

Config

cmds:
	# shell collection folder (can be an array of folder names)
	shellPath: "shell"
	
	# default collection name
	collectionName: "shell"
	
	# powershell path for windows (will also work in bash on windows)
	psPath: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell' # default

##Ordered Scripts

When using the "when" meta scripts are sorted by relativePath. This allows us to execute scripts in a specific order.

example:

# example script order with relative paths
task1.bash
task2.bash

task1\step1.bash
task1\step2.bash
task1\step3.bash

task2\step1.bash
task2\step2.bash
task2\step3.bash

##Env

Document attributes are added to the env (in full caps with an underscore seperator)

# bash
$DOCUMENT_TITLE, $DOCUMENT_FILENAME, etc..
$DOCPAD_CONFIG_ROOTPATH, $DOCPAD_CONFIG_OUTPATH, etc..
# ps1
$env:DOCUMENT_TITLE, $env:DOCUMENT_FILENAME, etc..
$env:DOCPAD_CONFIG_ROOTPATH, $env:DOCPAD_CONFIG_OUTPATH, etc..

powershell c# example

$source = @"
public class BasicTest
{
    public static int Add(int a, int b)
    {
        return (a + b);
    }

    public int Multiply(int a, int b)
    {
        return (a * b);
    }
}
"@

# load the source
Add-Type -TypeDefinition $source

# static ref
[BasicTest]::Add(4, 3)

# instance ref
$basicTestObject = New-Object BasicTest 
$basicTestObject.Multiply(5, 2)

History

You can discover the history inside the History.md file

Contributing

You can discover the contributing instructions inside the Contributing.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Stringz Solutions Ltd
Copyright © 2013+ Peter Flannery