@@ -2,17 +2,25 @@ module.exports = function(grunt) {
22 function getBanner ( isDemo ) {
33 return '/*!\n' +
44 ' * <%= pkg.name %>' + ( isDemo ? '-demo' : '' ) + ' - v<%= pkg.version %>\n' +
5- ' * @copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
5+ ' * @copyright 2015- <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
66 ' * @author Nick Wronski <nick@javascript.com>\n' +
77 ' */' ;
88 }
9+ const mochaCmd = './node_modules/.bin/mocha --compilers js:babel-core/register' ;
910 grunt . initConfig ( {
1011 pkg : grunt . file . readJSON ( 'package.json' ) ,
1112 browserify : {
13+ options : {
14+ transform : [ require ( 'babelify' ) . configure ( {
15+ sourceMapRelative : './' ,
16+ compact : true ,
17+ sourceMaps : true
18+ } ) ]
19+ } ,
1220 dist : {
1321 options : {
1422 browserifyOptions : {
15- debug : false ,
23+ debug : true ,
1624 standalone : 'sqliteParser'
1725 }
1826 } ,
@@ -73,37 +81,50 @@ module.exports = function(grunt) {
7381 }
7482 } ,
7583 clean : {
76- build : [ 'lib/*.js' ] ,
84+ build : [ '.tmp/*.js' , ' lib/*.js'] ,
7785 dist : [ 'dist/*.js' ] ,
7886 interactive : [ '.tmp/**/*' ] ,
7987 demo : [ 'demo/**/*' ]
8088 } ,
89+ concat : {
90+ options : {
91+ stripBanners : true ,
92+ // This imports the utilities used by the parser
93+ banner : "\nimport * as util from './parser-util';\n\nconst " ,
94+ // This exports the compiled parser
95+ footer : "\nexport default parser.parse;"
96+ } ,
97+ build : {
98+ src : [ '.tmp/parser.js' ] ,
99+ dest : 'lib/parser.js'
100+ }
101+ } ,
81102 shell : {
82103 build : {
83104 options : {
84105 failOnError : true
85106 } ,
86- command : './node_modules/.bin/pegjs --trace src/grammar.pegjs lib /parser.js'
107+ command : './node_modules/.bin/pegjs --trace -e parser src/grammar.pegjs .tmp /parser.js'
87108 } ,
88109 test : {
89110 options : {
90111 failOnError : true
91112 } ,
92- command : './node_modules/.bin/mocha --reporter=nyan'
113+ command : ` ${ mochaCmd } --reporter=nyan`
93114 } ,
94115 debug : {
95116 options : {
96117 failOnError : false ,
97118 debounceDelay : 500 ,
98119 forever : true
99120 } ,
100- command : ' DEBUG=true ./node_modules/.bin/mocha'
121+ command : ` DEBUG=true ${ mochaCmd } `
101122 } ,
102123 rewrite : {
103124 options : {
104125 failOnError : true
105126 } ,
106- command : ' REWRITE=true ./node_modules/.bin/mocha'
127+ command : ` REWRITE=true ${ mochaCmd } `
107128 }
108129 } ,
109130 connect : {
@@ -116,14 +137,25 @@ module.exports = function(grunt) {
116137 }
117138 } ,
118139 watch : {
140+ test : {
141+ options : {
142+ debounceDelay : 250 ,
143+ livereload : false
144+ } ,
145+ files : [
146+ 'index.js' , 'test/**/*.js' , 'src/*.js' , 'src/*.pegjs' ,
147+ 'test/sql/**/*.sql' , 'test/json/**/*.json' , 'Gruntfile.js'
148+ ] ,
149+ tasks : [ 'build' , 'shell:test' ]
150+ } ,
119151 debug : {
120152 options : {
121153 debounceDelay : 250 ,
122154 livereload : false
123155 } ,
124156 files : [
125- 'index.js' , 'test/*.js' , 'src/*.js' , 'src/*.pegjs' ,
126- 'test/sql/*.sql' , 'Gruntfile.js'
157+ 'index.js' , 'test/**/* .js' , 'src/*.js' , 'src/*.pegjs' ,
158+ 'test/sql/**/* .sql' , 'test/json/**/*.json ', 'Gruntfile.js'
127159 ] ,
128160 tasks : [ 'build' , 'shell:debug' ]
129161 } ,
@@ -227,11 +259,14 @@ module.exports = function(grunt) {
227259 'build'
228260 ] ) ;
229261 grunt . registerTask ( 'build' , [
230- 'clean:build' , 'shell:build' , 'copy:build'
262+ 'clean:build' , 'shell:build' , 'concat:build' , ' copy:build'
231263 ] ) ;
232264 grunt . registerTask ( 'test' , [
233265 'build' , 'shell:test'
234266 ] ) ;
267+ grunt . registerTask ( 'test-watch' , [
268+ 'test' , 'watch:test'
269+ ] ) ;
235270 grunt . registerTask ( 'debug' , [
236271 'build' , 'shell:debug' , 'watch:debug'
237272 ] ) ;
@@ -248,8 +283,11 @@ module.exports = function(grunt) {
248283 grunt . registerTask ( 'demo' , [
249284 'interactive' , 'clean:demo' , 'copy:demo' , 'uglify:demo' , 'usebanner:demo'
250285 ] ) ;
286+ grunt . registerTask ( 'minidist' , [
287+ 'default' , 'clean:dist' , 'browserify:dist'
288+ ] ) ;
251289 grunt . registerTask ( 'dist' , [
252- 'default' , 'clean:dist' , 'browserify:dist ', 'uglify:dist' , 'replace:dist' , 'usebanner:dist'
290+ 'minidist ' , 'uglify:dist' , 'replace:dist' , 'usebanner:dist'
253291 ] ) ;
254292 grunt . registerTask ( 'release' , [
255293 'test' , 'dist' , 'demo' , 'clean:interactive'
0 commit comments