-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
65 lines (59 loc) · 1.9 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Development Gruntfile for the "grunt-promise" NPM module.
*
* The MIT License (MIT)
* Copyright (c) 2016 Mark Halliwell
*/
(function () {
'use strict';
var grunt = require('grunt');
var Promise = require('./index.js').using();
// Grunt config initialization.
// -----------------------------------------------------------------------
grunt.initConfig({
bump: {
options: {
pushTo: 'origin'
}
},
nodeunit: {
all: ['test/*-test.js']
},
eslint: {
options: {
configFile: '.eslintrc'
},
js: [
'index.js',
'Gruntfile.js',
'lib/**/*.js',
'script/**/*.js',
'test/**/*.js'
]
}
});
// Load NPM grunt module tasks.
// -----------------------------------------------------------------------
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
// Register regular Grunt tasks.
// -----------------------------------------------------------------------
grunt.registerTask('default', ['test']);
grunt.registerTask('test', ['eslint', 'nodeunit']);
grunt.registerTask('test-before', grunt.log.writeln.bind(grunt.log, 'before finished'));
grunt.registerTask('test-after', grunt.log.writeln.bind(grunt.log, 'after finished'));
// Register Promised based Grunt task.
grunt.registerPromise('test-chaining', function () {
var math = require('./test/fixtures/math');
return math.add()
.then(math.multiply) // Expected value: 50
.then(math.multiply) // Expected value: 500
.then(math.multiply) // Expected value: 5000
.then(math.multiply) // Expected value: 50000
.then(function (value) {
var result = 'Result (' + Promise.gruntPromiseLibraryName + '): ' + value;
grunt.log.writeln(result); // Result: 50000
});
});
})();