Henrique Mendonça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 1 | //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 | |
| 7 | module.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 | } |
henrique | a2de410 | 2014-02-07 14:12:56 +0100 | [diff] [blame] | 38 | }, |
| 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ça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 58 | }, |
| 59 | qunit: { |
| 60 | all: { |
| 61 | options: { |
| 62 | urls: [ |
henrique | a2de410 | 2014-02-07 14:12:56 +0100 | [diff] [blame] | 63 | 'http://localhost:8088/test-nojq.html' |
Henrique Mendonça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 64 | ] |
| 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'); |
henrique | a2de410 | 2014-02-07 14:12:56 +0100 | [diff] [blame] | 87 | grunt.loadNpmTasks('grunt-external-daemon'); |
| 88 | grunt.loadNpmTasks('grunt-shell'); |
Henrique Mendonça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 89 | |
henrique | a2de410 | 2014-02-07 14:12:56 +0100 | [diff] [blame] | 90 | grunt.registerTask('test', ['jshint', 'shell', 'external_daemon', 'qunit']); |
| 91 | grunt.registerTask('default', ['jshint', 'shell', 'external_daemon', 'qunit', 'concat', 'uglify', 'jsdoc']); |
| 92 | }; |