1+ /*global module, require*/
2+ module . exports = function ( grunt ) {
3+ 'use strict' ;
4+
5+ // Project configuration.
6+ grunt . initConfig ( {
7+ meta : {
8+ src : [
9+ 'src/**/*.js' ,
10+ '!src/thirdparty/**' ,
11+ '!src/widgets/bootstrap-*.js' ,
12+ '!src/extensions/**/unittest-files/**/*.js' ,
13+ '!src/**/*-min.js' ,
14+ '!src/**/*.min.js'
15+ ] ,
16+ test : [
17+ 'test/**/*.js' ,
18+ '!test/perf/*-files/**/*.js' ,
19+ '!test/spec/*-files/**/*.js' ,
20+ '!test/smokes/**' ,
21+ '!test/temp/**' ,
22+ '!test/thirdparty/**'
23+ ] ,
24+ /* specs that can run in phantom.js */
25+ specs : [
26+ 'test/spec/CommandManager-test.js' ,
27+ 'test/spec/PreferencesManager-test.js' ,
28+ 'test/spec/ViewUtils-test.js'
29+ ]
30+ } ,
31+ watch : {
32+ test : {
33+ files : [ 'Gruntfile.js' , '<%= meta.src %>' , '<%= meta.test %>' ] ,
34+ tasks : 'test'
35+ }
36+ } ,
37+ /* FIXME (jasonsanjose): how to handle extension tests */
38+ jasmine : {
39+ src : 'undefined.js' , /* trick the default runner to run without importing src files */
40+ options : {
41+ junit : {
42+ path : 'test/results' ,
43+ consolidate : true
44+ } ,
45+ specs : '<%= meta.specs %>' ,
46+ /* Keep in sync with test/SpecRunner.html dependencies */
47+ vendor : [
48+ 'src/thirdparty/jquery-1.7.js' ,
49+ 'src/thirdparty/CodeMirror2/lib/codemirror.js' ,
50+ 'src/thirdparty/CodeMirror2/lib/util/dialog.js' ,
51+ 'src/thirdparty/CodeMirror2/lib/util/searchcursor.js' ,
52+ 'src/thirdparty/mustache/mustache.js'
53+ ] ,
54+ template : require ( 'grunt-template-jasmine-requirejs' ) ,
55+ templateOptions : {
56+ requireConfig : {
57+ baseUrl : 'src' ,
58+ paths : {
59+ 'test' : '../test' ,
60+ 'perf' : '../test/perf' ,
61+ 'spec' : '../test/spec' ,
62+ 'text' : 'thirdparty/text' ,
63+ 'i18n' : 'thirdparty/i18n'
64+ }
65+ }
66+ }
67+ }
68+ } ,
69+ jshint : {
70+ all : [
71+ 'Gruntfile.js' ,
72+ '<%= meta.src %>' ,
73+ '<%= meta.test %>'
74+ ] ,
75+ /* use strict options to mimic JSLINT until we migrate to JSHINT in Brackets */
76+ options : {
77+ jshintrc : '.jshintrc'
78+ }
79+ }
80+ } ) ;
81+
82+ // load dependencies
83+ grunt . loadNpmTasks ( 'grunt-contrib-jasmine' ) ;
84+ grunt . loadNpmTasks ( 'grunt-contrib-jshint' ) ;
85+ grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
86+
87+ // task: install
88+ grunt . registerTask ( 'install' , [ 'write-config' ] ) ;
89+
90+ // task: write-config
91+ // merge package.json and src/brackets.config.json into src/config.json
92+ grunt . registerTask ( 'write-config' , function ( ) {
93+ var packageJSON = grunt . file . readJSON ( "package.json" ) ,
94+ appConfigJSON = grunt . file . readJSON ( "src/brackets.config.json" ) ;
95+
96+ Object . keys ( packageJSON ) . forEach ( function ( key ) {
97+ if ( appConfigJSON [ key ] === undefined ) {
98+ appConfigJSON [ key ] = packageJSON [ key ] ;
99+ }
100+ } ) ;
101+
102+ grunt . file . write ( "src/config.json" , JSON . stringify ( appConfigJSON , null , " " ) ) ;
103+ } ) ;
104+
105+ // task: test
106+ grunt . registerTask ( 'test' , [ 'jshint' , 'jasmine' ] ) ;
107+
108+ // Default task.
109+ grunt . registerTask ( 'default' , [ 'test' ] ) ;
110+ } ;
0 commit comments