cspotcode / cspotcode/grunt-organized

Ensure registerTask ignores falsey values, making it easy to conditionally enable tasks

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

# Motivation:

You want to configure your build with flags passed to grunt on the command line.

``` bash
$ grunt --stage build
```

Access it in your gruntfile using `grunt.option`:

``` javascript
grunt.option('stage') // == true
```

Conditionally enable tasks based on a flag

```
grunt.registerTask('build', 'Build our code', {
jade: {/* ... */}
},
grunt.option('stage') && {
copy: {/* ... */} // a copy task that should only run if --stage was passed on the command line
});
```
# Implementation:

Ensure that our implementation of `grunt.registerTask` ignores all:
- falsey arguments
- falsey values on an object-type argument

For example:

```
grunt.registerTask('build', {
clean: grunt.options('clean-all') && {
// config for clean task
},
jade: {/* ... */}
});
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.