UNPKG

1.57 kBJavaScriptView Raw
1var fs = require("fs");
2var envify = require("envify/custom");
3
4module.exports = function(grunt) {
5 grunt.initConfig({
6 mochaTest: {
7 test: {
8 src: ["test/*.spec.js"]
9 }
10 },
11 envify: {
12 dev: {
13 env: {
14 NODE_ENV: "development"
15 },
16 input: "src/seamless-immutable.js",
17 output: "seamless-immutable.development.js"
18 },
19 prod: {
20 env: {
21 NODE_ENV: "production"
22 },
23 input: "src/seamless-immutable.js",
24 output: "seamless-immutable.production.min.js"
25 }
26 },
27 uglify: {
28 options: {
29 banner: '/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */'
30 },
31 min: {
32 files: {
33 "seamless-immutable.development.min.js": ["seamless-immutable.development.js"],
34 "seamless-immutable.production.min.js": ["seamless-immutable.production.min.js"]
35 }
36 }
37 }
38 });
39
40 grunt.loadNpmTasks("grunt-mocha-test");
41 grunt.loadNpmTasks("grunt-contrib-uglify");
42
43 grunt.registerMultiTask("envify", "Envifies a source file to a target file", function() {
44 var inputStream = fs.createReadStream(this.data.input);
45 var outputStream = fs.createWriteStream(this.data.output);
46
47 var done = this.async();
48
49 inputStream
50 .pipe(envify(this.data.env)())
51 .pipe(outputStream)
52 .on("finish", done);
53 });
54
55 grunt.registerTask("test", "mochaTest");
56 grunt.registerTask("build", ["envify", "uglify"]);
57 grunt.registerTask("default", ["build", "test"]);
58};