1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
| var projs = [
| 'tmerc',
| 'utm',
| 'sterea',
| 'stere',
| 'somerc',
| 'omerc',
| 'lcc',
| 'krovak',
| 'cass',
| 'laea',
| 'aea',
| 'gnom',
| 'cea',
| 'eqc',
| 'poly',
| 'nzmg',
| 'mill',
| 'sinu',
| 'moll',
| 'eqdc',
| 'vandg',
| 'aeqd',
| 'ortho'
| ];
| module.exports = function(grunt) {
| grunt.initConfig({
| pkg: grunt.file.readJSON('package.json'),
| connect: {
| server: {
| options: {
| port: process.env.PORT || 8080,
| base: '.'
| }
| }
| },
| mocha_phantomjs: {
| all: {
| options: {
| reporter: "dot",
| urls: [ //my ide requries process.env.IP and PORT
| "http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/amd.html",
| "http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/opt.html"
| ]
| }
| }
| },
| jshint: {
| options: {
| jshintrc: "./.jshintrc"
| },
| all: ['./lib/*.js', './lib/*/*.js']
| },
| browserify: {
| all: {
| files: {
| 'dist/proj4-src.js': ['lib/index.js'],
| },
| options: {
| browserifyOptions: {
| standalone: 'proj4'
| },
| alias: [
| './projs:./includedProjections'
| ]
| }
| }
| },
| uglify: {
| options: {
| report: 'gzip',
| mangle:{
| except: ['proj4','Projection','Point']
| },
| },
| all: {
| src: 'dist/proj4-src.js',
| dest: 'dist/proj4.js'
| }
| }
| });
| grunt.loadNpmTasks('grunt-browserify');
| grunt.loadNpmTasks('grunt-contrib-uglify');
| grunt.loadNpmTasks('grunt-contrib-jshint');
| grunt.loadNpmTasks('grunt-contrib-connect');
| grunt.loadNpmTasks('grunt-mocha-phantomjs');
| grunt.registerTask('custom',function(){
| grunt.task.run('browserify', 'uglify');
| var projections = this.args;
| if(projections[0]==='default'){
| grunt.file.write('./projs.js','module.exports = function(){}');
| return;
| }
| if(projections[0]==='all'){
| projections = projs;
| }
| grunt.file.write('./projs.js',[
| "var projs = [",
| " require('./lib/projections/"+projections.join("'),\n\trequire('./lib/projections/")+"')",
| "];",
| "module.exports = function(proj4){",
| " projs.forEach(function(proj){",
| " proj4.Proj.projections.add(proj);",
| " });",
| "}"
| ].join("\n"));
| });
| grunt.registerTask('build',function(){
| var args = this.args.length?this.args[0].split(','):['default'];
| grunt.task.run('jshint', 'custom:'+args.join(':'));
| });
| grunt.registerTask('default', ['build:all', 'connect','mocha_phantomjs']);
| };
|
|