forked from sociomantic-tsunami/microbe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (85 loc) · 3.1 KB
/
gulpfile.js
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
var gulp = require( 'gulp' );
var fs = require( 'fs' );
var replace = require( 'gulp-replace' );
var uglify = require( 'gulp-uglify' );
var rename = require( 'gulp-rename' );
var header = require( 'gulp-header' );
var browserify = require( 'browserify' );
var Nightmare = require( 'nightmare' );
var _name = 'microbe';
var now = new Date();
var _package = require( './package.json' );
var liscenceLong = '/*!\n' +
' * Microbe JavaScript Library v' + _package.version + '\n' +
' * ' + _package.homepage + '\n' +
' *\n' +
' * Copyright 2014-' + now.getUTCFullYear() + ' Sociomantic Labs and other contributors\n' +
' * Released under the MIT license\n' +
' * http://m.icro.be/license\n' +
' *\n' +
' * Date: ' + now.toDateString() + '\n' +
' */\n';
var liscenceShort = '/*! Microbe v' + _package.version + ' | (c) 2014-' + now.getUTCFullYear() + ' Sociomantic Labs | http://m.icro.be/license */\n';
var token = 'ThisIsVeryUnlikelyThatAVariableWillBeCalledThisWay';
var exportName = 'µ';
gulp.task( 'build', function()
{
browserify( './src/' + _name + '.js', { standalone: token } )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/dist/' + _name + '.js' ) )
.on( 'finish', function()
{
gulp.src( './dist/' + _name + '.js' )
.pipe( replace( token, exportName ) )
.pipe( header( liscenceLong ) )
.pipe( gulp.dest( './dist/' ) );
} );
} );
gulp.task( 'buildTests', function()
{
browserify( './tests/buildTests.js' )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/tests/tests.js' ) )
.on( 'finish', function()
{
gulp.src( './tests/tests.js' )
.pipe( gulp.dest( './tests/' ) );
} );
});
gulp.task( 'min', function()
{
browserify( './src/' + _name + '.js', { standalone: token } )
.bundle()
.pipe( fs.createWriteStream( __dirname + '/dist/' + _name + '.min.js' ) )
.on( 'finish', function()
{
gulp.src( './dist/' + _name + '.min.js' )
.pipe( replace( token, exportName ) )
.pipe( uglify() )
.pipe( header( liscenceShort ) )
.pipe( gulp.dest( './dist/' ) );
});
});
gulp.task( 'default', [], function()
{
gulp.start( [ 'build', 'min', 'buildTests', 'test' ] );
} );
gulp.task( 'microbe', function()
{
_name = 'microbe';
gulp.start( [ 'build', 'min' ] );
} );
gulp.task( 'selectorEngine', function()
{
_name = 'microbe.selectorEngine';
gulp.start( [ 'build', 'min' ] );
} );
gulp.task( 'toolkit', function()
{
_name = 'microbe.toolkit';
gulp.start( [ 'build', 'min' ] );
} );
gulp.task( 'watch', function()
{
gulp.watch( [ 'src/**/*.js', 'tests/unit/*.js', 'tests/unit/**/*.js' ], [ 'default' ] );
} );