master
Raw Download raw file
 1module.exports = function(grunt) {
 2    "use strict";
 3
 4    grunt.initConfig({
 5	meta: {
 6	    user: grunt.option("user") || "nimvek",
 7	},
 8        clean: {
 9	    build: [ "build/" ],
10	    release: [ "release/" ],
11	},
12        copy: {
13            pre: {
14                expand: true,
15                flatten: true,
16                src: [ "tools/*.js", "hacking/*.js" ],
17                dest: "build/",
18                options: {
19                    process: function(content) {
20                        return content.replace(/#s\./g, "SCRIPTOR.").replace(/#db\./g, "DATABASE.").replace(/([\s\S]*)/, "($1)();").replace(/INCLUDE\((\w+)\)/g, function (match,name) { return "var "+name+" = " + grunt.file.read("lib/"+name+".js")+";"; });
21                    }
22                }
23            },
24            post: {
25                expand: true,
26                flatten: true,
27                src: [ "build/*.js" ],
28                dest: "release/",
29                options: {
30                    process: function(content) {
31                        return content.replace(/^\!([\s\S]*)\(\);$/, "$1").replace(/^\(([\s\S]*)\)\(\);$/, "$1").replace(/SCRIPTOR\./g, "#s.").replace(/DATABASE\./g, "#db.").replace(/LIBRARY/g, grunt.template.process("#s.<%= meta.user %>.lib()"));
32                    }
33                }
34            }
35        },
36	concat: {
37	    lib: {
38		options: {
39		    banner: "(function () {\nvar l = SCRIPTOR.scripts.lib();\nreturn {\n",
40		    footer: "};\n})();",
41		    separator: ",\n",
42		    process: function(src, filepath) {
43			var path = require('path');
44			return path.basename(filepath, ".js") + ": " + src.replace(/\s*$/, "");
45		    }
46		},
47		files: {
48		"build/lib.js": [ "lib/*.js" ],
49		},
50	    },
51	},
52        jshint: {
53            files: [ "Gruntfile.js", "build/*.js" ]
54        },
55        uglify: {
56            all: {
57                files: [ {
58                    expand: true,
59                    src: "build/*.js",
60                } ]
61            }
62        }
63    });
64
65    grunt.loadNpmTasks("grunt-contrib-clean");
66    grunt.loadNpmTasks("grunt-contrib-copy");
67    grunt.loadNpmTasks("grunt-contrib-concat");
68    grunt.loadNpmTasks("grunt-contrib-jshint");
69    grunt.loadNpmTasks("grunt-contrib-uglify");
70
71    grunt.registerTask("default", [ "clean", "copy:pre", "concat", "jshint", "uglify", "copy:post", "clean:build" ]);
72};