blob: 9a8bb0d19ef1a34ab0ac7efc1f0e49be169e6d30 [file] [log] [blame]
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001//To build dist/thrift.js, dist/thrift.min.js and doc/*
2//run grunt at the command line in this directory.
3//Prerequisites:
4// Node Setup - nodejs.org
5// Grunt Setup - npm install //reads the ./package.json and installs project dependencies
6
7module.exports = function(grunt) {
8 'use strict';
9
10 grunt.initConfig({
11 pkg: grunt.file.readJSON('package.json'),
12 concat: {
13 options: {
14 separator: ';'
15 },
16 dist: {
17 src: ['src/**/*.js'],
18 dest: 'dist/<%= pkg.name %>.js'
19 }
20 },
21 jsdoc : {
22 dist : {
23 src: ['src/*.js', './README'],
24 options: {
25 destination: 'doc'
26 }
27 }
28 },
29 uglify: {
30 options: {
31 banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
32 },
33 dist: {
34 files: {
35 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
36 }
37 }
henriquea2de4102014-02-07 14:12:56 +010038 },
39 shell: {
40 InstallThriftJS: {
41 command: 'mkdir test/build; mkdir test/build/js; cp src/thrift.js test/build/js/thrift.js'
42 },
43 ThriftGen: {
44 command: 'thrift -gen js -gen js:node -o test ../../test/ThriftTest.thrift'
45 }
46 },
47 external_daemon: {
48 ThriftTestServer: {
49 options: {
50 startCheck: function(stdout, stderr) {
51 return (/Thrift Server running on port/).test(stdout);
52 },
53 nodeSpawnOptions: {cwd: "test"}
54 },
55 cmd: "node",
56 args: ["server_http.js"]
57 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +020058 },
59 qunit: {
60 all: {
61 options: {
62 urls: [
henriquea2de4102014-02-07 14:12:56 +010063 'http://localhost:8088/test-nojq.html'
Henrique Mendonça095ddb72013-09-20 19:38:03 +020064 ]
65 }
66 }
67 },
68 jshint: {
69 files: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
70 options: {
71 // options here to override JSHint defaults
72 globals: {
73 jQuery: true,
74 console: true,
75 module: true,
76 document: true
77 }
78 }
79 },
80 });
81
82 grunt.loadNpmTasks('grunt-contrib-uglify');
83 grunt.loadNpmTasks('grunt-contrib-jshint');
84 grunt.loadNpmTasks('grunt-contrib-qunit');
85 grunt.loadNpmTasks('grunt-contrib-concat');
86 grunt.loadNpmTasks('grunt-jsdoc');
henriquea2de4102014-02-07 14:12:56 +010087 grunt.loadNpmTasks('grunt-external-daemon');
88 grunt.loadNpmTasks('grunt-shell');
Henrique Mendonça095ddb72013-09-20 19:38:03 +020089
henriquea2de4102014-02-07 14:12:56 +010090 grunt.registerTask('test', ['jshint', 'shell', 'external_daemon', 'qunit']);
91 grunt.registerTask('default', ['jshint', 'shell', 'external_daemon', 'qunit', 'concat', 'uglify', 'jsdoc']);
92};