Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 211c7bb

Browse files
committed
Do not bundle demo and parser together. Refs #15
I was browserifying the parser together with the demo code and CodeMirror but having the parser bundle included in the real sqlite-parser.js format has the added benefit of testing that the library does indeed make itself available on window.sqliteParser when it is dropped into a script tag on a web page.
1 parent dba0692 commit 211c7bb

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

Gruntfile.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ module.exports = function(grunt) {
3030
interactive: {
3131
options: {
3232
alias: {
33-
'sqlite-parser': './index',
34-
'sqlite-parser-util': './lib/parser-util',
3533
'codemirror': './node_modules/codemirror/lib/codemirror',
3634
'foldcode': './node_modules/codemirror/addon/fold/foldcode',
3735
'foldgutter': './node_modules/codemirror/addon/fold/foldgutter',
@@ -42,7 +40,6 @@ module.exports = function(grunt) {
4240
},
4341
},
4442
require: [
45-
'lib/parser-util.js', 'lib/parser.js', './index.js',
4643
'node_modules/codemirror/lib/codemirror',
4744
'node_modules/codemirror/addon/fold/foldcode',
4845
'node_modules/codemirror/addon/fold/foldgutter',
@@ -67,10 +64,15 @@ module.exports = function(grunt) {
6764
},
6865
interactive: {
6966
files: [{
70-
src: ['src/demo/index.html'],
71-
flatten: true,
67+
src: ['index.html'],
7268
expand: true,
69+
cwd: 'src/demo/',
7370
dest: '.tmp/'
71+
}, {
72+
src: ['sqlite-parser.js'],
73+
expand: true,
74+
cwd: 'dist/',
75+
dest: '.tmp/js/'
7476
}],
7577
},
7678
demo: {
@@ -159,7 +161,7 @@ module.exports = function(grunt) {
159161
],
160162
tasks: ['build', 'shell:debug']
161163
},
162-
live: {
164+
interactive: {
163165
options: {
164166
debounceDelay: 1000,
165167
livereload: {
@@ -168,7 +170,7 @@ module.exports = function(grunt) {
168170
},
169171
},
170172
files: [
171-
'index.js', 'src/**/*.{js,pegjs,css,html}', 'Gruntfile.js'
173+
'index.js', 'src/**/*.{js,css,html,pegjs}', 'Gruntfile.js'
172174
],
173175
tasks: ['interactive']
174176
}
@@ -187,7 +189,8 @@ module.exports = function(grunt) {
187189
},
188190
demo: {
189191
files: {
190-
'demo/js/sqlite-parser-demo.js': ['.tmp/js/sqlite-parser-demo.js']
192+
'demo/js/sqlite-parser-demo.js': ['.tmp/js/sqlite-parser-demo.js'],
193+
'demo/js/sqlite-parser.js': ['.tmp/js/sqlite-parser.js']
191194
}
192195
}
193196
},
@@ -229,6 +232,7 @@ module.exports = function(grunt) {
229232
files: {
230233
src: [
231234
'demo/js/sqlite-parser-demo.js',
235+
'demo/css/sqlite-parser-demo.css'
232236
]
233237
}
234238
}
@@ -274,20 +278,20 @@ module.exports = function(grunt) {
274278
'build', 'shell:rewrite'
275279
]);
276280
grunt.registerTask('interactive', [
277-
'clean:interactive', 'default', 'copy:interactive', 'cssmin:interactive',
278-
'browserify:interactive'
281+
'clean:interactive', 'minidist', 'copy:interactive',
282+
'cssmin:interactive', 'browserify:interactive'
279283
]);
280284
grunt.registerTask('live', [
281-
'interactive', 'connect:server', 'watch:live'
285+
'interactive', 'connect:server', 'watch:interactive'
282286
]);
283287
grunt.registerTask('demo', [
284288
'interactive', 'clean:demo', 'copy:demo', 'uglify:demo', 'usebanner:demo'
285289
]);
286290
grunt.registerTask('minidist', [
287-
'default', 'clean:dist', 'browserify:dist'
291+
'default', 'clean:dist', 'browserify:dist', 'replace:dist'
288292
]);
289293
grunt.registerTask('dist', [
290-
'minidist', 'uglify:dist', 'replace:dist', 'usebanner:dist'
294+
'minidist', 'uglify:dist', 'usebanner:dist'
291295
]);
292296
grunt.registerTask('release', [
293297
'test', 'dist', 'demo', 'clean:interactive'

src/demo/demo.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/**
22
* sqlite-parser demo
33
*/
4-
import sqliteParser from 'sqlite-parser';
5-
import {extend} from 'sqlite-parser-util';
64
import CodeMirror from 'codemirror';
75

86
require('foldgutter');
@@ -105,10 +103,10 @@ document.addEventListener('DOMContentLoaded', function () {
105103
tabSize: 4,
106104
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
107105
},
108-
sql = CodeMirror.fromTextArea(elemSql, extend({
106+
sql = CodeMirror.fromTextArea(elemSql, Object.assign({
109107
mode: 'text/x-plsql'
110108
}, cmDefaults)),
111-
ast = CodeMirror.fromTextArea(elemAst, extend({
109+
ast = CodeMirror.fromTextArea(elemAst, Object.assign({
112110
mode: "application/ld+json",
113111
foldGutter: true,
114112
readOnly: true

src/demo/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ <h3>
5757
&copy; 2015 <a href="http://codeschool.com" title="Code School">Code School</a>
5858
</h3>
5959
</footer>
60-
60+
61+
<!-- sqliteParser Bundle -->
62+
<script src="js/sqlite-parser.js"></script>
6163
<!-- CodeMirror Setup -->
6264
<script src="js/sqlite-parser-demo.js"></script>
6365
</body>

0 commit comments

Comments
 (0)