Skip to content

Commit

Permalink
update utils documentation to table formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle MacDonald committed May 18, 2015
1 parent e362ef7 commit d4b2692
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,17 @@ Sprout comes with the following events for you to write custom logic for. Each h

The utilities object passed to each hook contains the following functions (each returns a promise):

- `utils.copy(from, to)` - copy a file at `from` (relative to the template's _base_ directory) to the path at `to` (relative to the template's _target_ directory).
- `utils.src.read(from)` - read a file at `from` (relative to the template's _base_ directory).
- `utils.target.copy(from, to)` - copy a file at `from` (relative to the template's _target_ directory) to the path at `to` (relative to the template's _target_ directory).
- `utils.target.read(from)` - read a file at `from` (relative to the template's _target_ directory).
- `utils.target.write(to, what, locals)` - write `what` to path `to` (relative to the template's _target_ directory), optionally with ejs locals at `locals`.
- `utils.target.rename(from, to)` - rename file at `from` to path at `to` (relative to the template's _target_ directory).
- `utils.target.remove(what)` - remove files; pass a path or an array of paths (relative to the template's _target_ directory).
- `utils.target.exec(cmd, cwd)` - run a child process with the _target_ directory set at the current working directory by default; optionally, pass a path to `cwd` (relative to the target directory).
function | description
:------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------
`utils.copy(from, to)` | copy a file at `from` (relative to the template's _base_ directory) to the path at `to` (relative to the template's _target_ directory).
`utils.src.read(from)` | read a file at `from` (relative to the template's _base_ directory).
`utils.target.copy(from, to)` | copy a file at `from` (relative to the template's _target_ directory) to the path at `to` (relative to the template's _target_ directory).
`utils.target.read(from)` | read a file at `from` (relative to the template's _target_ directory).
`utils.target.write(to, what, locals)` | write `what` to path `to` (relative to the template's _target_ directory), optionally with ejs locals at `locals`.
`utils.target.rename(from, to)` | rename file at `from` to path at `to` (relative to the template's _target_ directory).
`utils.target.remove(what)` | remove files; pass a path or an array of paths (relative to the template's _target_ directory).
`utils.target.exec(cmd, cwd)` | run a child process with the _target_ directory set at the current working directory by default; optionally, pass a path to `cwd` (relative to the target directory).


### Generators
Sprout templates may also include "generators": small scripts to be executed on instances of a template. For example, an `mvc` template may include `model`, `controller`, and `view` generators for quickly stubbing out an model-view-controller application. Generators are passed `utils` (an instance of the `Utils` that reads from the _base_ directory and writes to the _target_ directory) in the first argument; any arguments passed to `sprout.run()` follow. A model generator in an `mvc` template may look like this:
Expand Down

0 comments on commit d4b2692

Please sign in to comment.