UNPKG

5.01 kBMarkdownView Raw
1# load-common-gulp-tasks [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
2> Load common [gulp](http://gulpjs.com/) tasks and configs so you don't need to redefine them for every module
3
4Supplies a common interface to the following gulp modules:
5
61. [gulp-mocha](https://github.com/sindresorhus/gulp-mocha)
72. [gulp-jshint](https://github.com/spenceralger/gulp-jshint)
83. [gulp-istanbul](https://github.com/SBoudrias/gulp-istanbul)
94. [gulp-istanbul-enforcer](https://github.com/iainjmitchell/gulp-istanbul-enforcer)
105. [gulp-plato](https://github.com/sindresorhus/gulp-plato)
116. [gulp-help](https://github.com/chmontgomery/gulp-help)
126. [gulp-nice-package](https://github.com/chmontgomery/gulp-nice-package)
136. [gulp-shrinkwrap](https://github.com/chmontgomery/gulp-shrinkwrap)
14
15## Available Tasks
16
17`gulp help` for available tasks. Right now these are the default tasks:
18
19![](screenshot.png)
20
21### Debug Tests
22
23You can debug your mocha tests using a tool like [node-inspector](https://github.com/node-inspector/node-inspector)
24combined with the `gulp test-debug` target
25
26## Basic Usage
27
28```js
29// gulpfile.js
30var gulp = require('load-common-gulp-tasks')(require('gulp'));
31```
32
33## Options
34
35`load-common-gulp-tasks` tries to assume smart defaults but also attempts to be very configurable.
36Each option can be overridden by passing an `options` object as the second parameter,
37e.g. `require('load-common-gulp-tasks')(gulp, options);`
38
39### options.istanbul
40
41Type: `Object`
42
43Default:
44```js
45{
46 includeUntested: true
47}
48```
49
50[See here for all available options](https://github.com/SBoudrias/gulp-istanbul#istanbulopt)
51
52### options.istanbulWriteReports
53
54Type: `Object`
55
56Default:
57```js
58{
59 dir: './target/coverage'
60}
61```
62
63[See here for all available options](https://github.com/SBoudrias/gulp-istanbul#istanbulwritereportsopt)
64
65### options.istanbulEnforcer
66
67Type: `Object`
68
69Default:
70```js
71{
72 thresholds: {
73 statements: 80,
74 branches: 70,
75 lines: 80,
76 functions: 80
77 },
78 coverageDirectory: './target/coverage',
79 rootDirectory: ''
80}
81```
82
83[See here for all available options](https://github.com/iainjmitchell/gulp-istanbul-enforcer#options)
84
85### options.paths
86
87Type: `Object`
88
89Default:
90```js
91{
92 lint: [
93 './*.js',
94 './lib/**/*.js',
95 './test/**/*.js'
96 ],
97 felint: [
98 './content/**/*.js'
99 ],
100 cover: [
101 './lib/**/*.js'
102 ],
103 test: [
104 './test/**/*.js'
105 ]
106}
107```
108
109Glob paths used by the associated targets
110
111### options.jshintrc.server
112
113Type: `String`
114
115Default: `node_modules/load-common-gulp-tasks/lint/.jshintrc`
116
117`.jshintrc` file to use when running `gulp lint` target
118
119### options.jshintrc.client
120
121Type: `String`
122
123Default: `node_modules/load-common-gulp-tasks/felint/.jshintrc`
124
125`.jshintrc` file to use when running `gulp felint` target
126
127### options.complexity.destDir
128
129Type: `String`
130
131Default: `./target/complexity`
132
133Report destination.
134
135### options.complexity.options
136
137Type: `Object`
138
139Default: `{}`
140
141[Options](https://github.com/philbooth/complexity-report#command-line-options) passed to complexity-report.
142
143### options.showStreamSize
144
145Type: `Boolean`
146
147Default: `false`
148
149Optionally show the gulp stream size of each task
150
151### options.nicePackage.spec
152
153Type: `String`
154
155Default: `npm`
156
157spec option for [package.json-validator](https://github.com/gorillamania/package.json-validator#api)
158
159### options.nicePackage.options
160
161Type: `Object`
162
163Default:
164```js
165{
166 warnings: false,
167 recommendations: false
168}
169```
170
171spec option for [package.json-validator](https://github.com/gorillamania/package.json-validator#api)
172
173## Advanced Usage
174
175To override default tasks or create new ones, simply define them after calling `require('load-common-gulp-tasks')(gulp);` in your `gulpfile.js`, e.g.
176
177```js
178var gulp = require('gulp'),
179 sass = require('gulp-sass'),
180 sassFiles = './lib/*/sass/*.scss',
181 options;
182
183// ------------------------
184// custom coverage settings
185// ------------------------
186options = {
187 istanbulEnforcer: {
188 thresholds: {
189 statements: 83, // higher than default
190 branches: 59, // lower than default
191 // lines not defined. use default
192 functions: 58
193 }
194 }
195};
196
197// ------------------------
198// load common tasks
199// ------------------------
200require('load-common-gulp-tasks')(gulp, options);
201
202// ------------------------
203// custom tasks
204// ------------------------
205gulp.task('watch', 'Watch sass files and recompile on change', function () {
206 gulp.watch(sassFiles, ['styles']);
207});
208
209gulp.task('styles', 'Compile sass to css', function () {
210 return gulp.src(sassFiles)
211 .pipe(sass())
212 .pipe(gulp.dest('./public'));
213});
214```
215
216## License
217
218[MIT](http://opensource.org/licenses/MIT) © [Chris Montgomery](http://www.chrismontgomery.info/)
219
220[npm-url]: https://npmjs.org/package/load-common-gulp-tasks
221[npm-image]: http://img.shields.io/npm/v/load-common-gulp-tasks.svg
222[travis-image]: https://travis-ci.org/areusjs/load-common-gulp-tasks.svg?branch=master
223[travis-url]: https://travis-ci.org/areusjs/load-common-gulp-tasks
\No newline at end of file