forked from amida-tech/blue-button
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
190 lines (178 loc) · 6.26 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*global module*/
var bb = require('./index');
var path = require('path');
var generateChangeDetectionFiles = function (grunt) {
var srcs = [
'test/fixtures/parser-c32/VA_CCD_Sample_File_Version_12_5_1.xml',
'test/fixtures/parser-ccd/SampleCCDDocument.xml',
'test/fixtures/parser-ccda/CCD_1.xml'
];
var dest = 'test/fixtures/generated';
srcs.forEach(function (src) {
var content = grunt.file.read(src);
var sensed = bb.senseString(content);
var cms = sensed.type === 'cms';
var result = cms ? bb.parseText(content) : bb.parseString(content);
var baseName = path.basename(src, path.extname(src));
var destName = baseName + '.json';
var destPath = path.join(dest, destName);
var destContent = JSON.stringify(result, undefined, 2);
grunt.file.write(destPath, destContent);
});
};
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-shell');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['*.js', './lib/**/*.js', './test/**/*.js'],
options: {
browser: true,
smarttabs: true,
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: false,
boss: true,
eqnull: true,
node: true,
expr: true,
globals: {
'it': true,
'xit': true,
'describe': true,
'before': true,
'after': true,
'done': true
}
}
},
watch: {
all: {
files: ['./lib/**/*.js', '*.js', './test/**/*.js'],
tasks: ['default']
}
},
jsbeautifier: {
beautify: {
src: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
config: '.jsbeautifyrc'
}
},
check: {
src: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
mode: 'VERIFY_ONLY',
config: '.jsbeautifyrc'
}
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
timeout: '10000',
recursive: true
},
src: ['test/**/*.js']
}
},
coveralls: {
options: {
// LCOV coverage file relevant to every target
src: 'coverage/lcov.info',
// When true, grunt-coveralls will only print a warning rather than
// an error, to prevent CI builds from failing unnecessarily (e.g. if
// coveralls.io is down). Optional, defaults to false.
force: false
},
//your_target: {
// Target-specific LCOV coverage file
//src: 'coverage-results/extra-results-*.info'
//},
},
browserify: {
require: {
src: ['<%=pkg.main%>'],
dest: 'dist/<%=pkg.name%>.js',
options: {
alias: [__dirname + "/index.js:<%=pkg.name%>"],
external: ["blue-button-xml", "blue-button-cms"],
browserifyOptions: {
ignoreMissing: true
}
}
},
tests: {
src: ['test/**/*.js'],
dest: 'dist/mocha_tests.js',
options: {
external: ["blue-button-xml", "blue-button-cms"],
transform: ['brfs'],
browserifyOptions: {
ignoreMissing: true
}
}
}
},
connect: {
server: {
options: {
port: 8000,
hostname: '127.0.0.1'
}
}
},
'mocha_phantomjs': {
all: {
options: {
urls: [
'http://127.0.0.1:8000/dist/mocha_runner.html'
]
}
}
},
shell: {
run_istanbul: {
command: "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --recursive"
}
}
});
grunt.registerTask('browser-test', ['browserify:require', 'browserify:tests', 'connect:server', 'mocha_phantomjs']);
grunt.registerTask('gen-change-detect', 'generates files to detect changes in generation', function () {
generateChangeDetectionFiles(grunt);
});
// Default task.
grunt.registerTask('default', ['beautify', 'jshint', 'mochaTest']); //, 'browser-test', 'gen-change-detect']);
//Express omitted for travis build.
grunt.registerTask('commit', ['jshint', 'mochaTest']);
grunt.registerTask('mocha', ['mochaTest']);
grunt.registerTask('timestamp', function () {
grunt.log.subhead(Date());
});
grunt.registerTask('coverage', ['shell:run_istanbul']);
// Alias the `generator:ccda_samples` task to run `mocha test --recursive --grep generator` instead
grunt.registerTask('generator:ccda_samples', 'mocha test --recursive --grep [ccda_samples]', function () {
var done = this.async();
require('child_process').exec('mocha test --recursive --grep ccda_samples', function (err, stdout) {
grunt.log.write(stdout);
done(err);
});
});
//JS beautifier
grunt.registerTask('beautify', ['jsbeautifier:beautify']);
};