Pakefiles

TravisPaul edited this page Feb 19, 2013 · 2 revisions

Pakefile, first of all, is a PHP file, so all usual rules apply: Pakefiles are started with <?php line, consist of statements and declarations.

Pakefiles can use one of the following names:

  • pakefile
  • Pakefile
  • pakefile.php
  • Pakefile.php

Defining tasks

To define a task, we need to do 3 things:

pake_desc('Description of foo task'); // 1. describe a task
pake_task('foo'); // 2. give task a name
function run_foo()
{
    pake_echo('I am the "foo" task'); // 3. define, what task will do
}

Now, we can run some commands and see the result:

> pake -T
available pake tasks:
  foo  > Description of foo task

> pake foo
I am the "foo" task

Tasks can have dependencies. For example, we can add another task to our pakefile, like this:

pake_desc('Description of bar task');
pake_task('bar', 'foo'); // second and the following parameters list tasks, which current task depends on
function run_bar()
{
    pake_echo('I am the "BAR" task');
}

Now, let’s run this new task:

> pake bar
I am the "foo" task
I am the "BAR" task

As “bar” task depends on “foo” task, “foo” task was executed first.