UNPKG

1.57 kBJavaScriptView Raw
1/*!
2 * Copyright (c) 2012-2018 Digital Bazaar, Inc. All rights reserved.
3 */
4'use strict';
5
6module.exports = function(grunt) {
7 'use strict';
8
9 // init config
10 grunt.initConfig({});
11
12 // set mode to either 'default' or 'ci'
13 grunt.config('mode',
14 grunt.option('mode') || process.env.GRUNT_MODE || 'default');
15 // check for ci mode
16 grunt.config('ci', grunt.option('mode') === 'ci');
17
18 // setup config vars for templating
19 grunt.config('dirs', {
20 'bedrock': __dirname,
21 // main project dir, override for subprojects
22 'main': __dirname
23 });
24
25 // read package configuration
26 grunt.config('pkg', grunt.file.readJSON('package.json'));
27
28 grunt.config('js', [
29 '*.js',
30 'bin/*.js',
31 'bin/**/*.js',
32 'configs/*.js',
33 'lib/*.js',
34 'lib/**/*.js'
35 //'tests/*.js',
36 //'tests/**/*.js'
37 ]);
38
39 // _jshint
40 grunt.loadNpmTasks('grunt-contrib-jshint');
41 grunt.config('jshint', {
42 all: {
43 options: grunt.config('ci') ? {
44 jshintrc: true,
45 reporter: 'checkstyle',
46 reporterOutput: 'reports/jshint.xml'
47 } : {
48 jshintrc: true
49 },
50 src: grunt.config('js')
51 }
52 });
53
54 var _jscsOptions = {
55 config: '<%= dirs.bedrock %>/.jscsrc',
56 excludeFiles: []
57 };
58 if(grunt.config('ci')) {
59 _jscsOptions.reporter = 'checkstyle';
60 _jscsOptions.reporterOutput = 'reports/jscs.xml';
61 }
62
63 grunt.loadNpmTasks('grunt-jscs');
64 grunt.config('jscs', {
65 all: {
66 options: _jscsOptions,
67 src: grunt.config('js')
68 }
69 });
70
71 // default tasks
72 grunt.registerTask('default', []);
73};