Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app global vars #313

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add docs for setAppVars
Karpich Dmitry committed Feb 12, 2016
commit e0694320be9b8dd9df765a1d74ae8e8422c1350e
36 changes: 36 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -334,6 +334,42 @@ command. You can do this by adding this line to your `.zshrc` file :

alias jake="noglob jake"

### Setup jake program global settings

Jake supports the ability to setup global settings (to program) and later use this settings in tasks.

This is may be useful when tasks was split to some files in `jakelib` but must use some settings, f.e. path to directory:

```javascript
// At Jakefile
jake.program.setAppVars('libDir', '../foo/lib');
jake.program.setAppVars({'srcDir': '../bazz/src', 'binDir': '../foo/bin'});
```

And later use it:

```javascript
// At jakelib/common.jake
desc('Clear lib.');
task('clearLib', function () {
var libDir = jake.program.appVars.libDir;
// Do something with libDir value
});
```

```javascript
// At jakelib/build.jake
desc('Build lib.');
task('buildLib', function () {
var libDir = jake.program.appVars.libDir,
srcDir = jake.program.appVars.srcDir,
binDir = jake.program.appVars.binDir;
// Do something with libDir value
});
```

With application variables it will be easy to have one source of settings to rule it.

### Cleanup after all tasks run, jake 'complete' event

The base 'jake' object is an EventEmitter, and fires a 'start' event before