Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 1 | var assert = require('assert'); |
| 2 | var fs = require('fs'); |
| 3 | var path = require('path'); |
| 4 | |
| 5 | module.exports = function(grunt) { |
| 6 | require('load-grunt-tasks')(grunt); |
| 7 | grunt.task.loadTasks('grunt_tasks'); |
| 8 | |
| 9 | grunt.initConfig({ |
| 10 | pkg: grunt.file.readJSON('package.json'), |
| 11 | jshint: { |
| 12 | files: ['**/*.js'], |
| 13 | options: { |
| 14 | ignores: ['**/veyron*.js', |
| 15 | 'node_modules/**/*.js'] |
| 16 | } |
| 17 | } |
| 18 | }); |
| 19 | |
Jiri Simsa | 9cb628d | 2014-05-10 10:05:50 -0700 | [diff] [blame] | 20 | var vIndex = __dirname.indexOf('/go/'); |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 21 | assert.notEqual(vIndex, -1, 'Failed to find Veyron root dir'); |
| 22 | |
| 23 | grunt.constants = { |
| 24 | LOG_DIR: path.resolve('log'), |
Jiri Simsa | 9cb628d | 2014-05-10 10:05:50 -0700 | [diff] [blame] | 25 | VEYRON_BIN_DIR: __dirname.substr(0, vIndex) + '/go/bin', |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 26 | VEYRON_IDENTITY_PORT: 3000, |
| 27 | VEYRON_PROXY_PORT: 3001, |
| 28 | VEYRON_WSPR_PORT: 3002 |
| 29 | }; |
| 30 | var c = grunt.constants; |
| 31 | |
| 32 | // Make dirs as needed. |
| 33 | [c.LOG_DIR].forEach(function(dir) { |
| 34 | if (!fs.existsSync(dir)) fs.mkdirSync(dir); |
| 35 | }); |
| 36 | |
| 37 | // Starts all needed daemons and blocks. On Ctrl-C, kills all spawned |
| 38 | // subprocesses and then exits. |
| 39 | grunt.registerTask('start', [ |
| 40 | 'subtask_spawnSubprocesses' |
| 41 | ]); |
| 42 | }; |