This repository has been archived by the owner on Mar 27, 2018. It is now read-only.
forked from cmelbye/jwysiwyg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
JakeFile
113 lines (86 loc) · 2.86 KB
/
JakeFile
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 fs = require('fs'),
path = require('path');
var release = {
name: 'bootstrap.wysiwyg.js',
description: 'Bootstrap jWYSIWYG Plugin',
version: '0.9',
paths: {
src: path.normalize('./src'),
dist: path.normalize('./dist'),
build: path.normalize('./build')
},
files: [
'prefix', 'core', 'utils', 'editor', 'dom', 'selection',
'toolbar', 'dialog', 'plugins', 'suffix'
],
output: {
standard: 'bootstrap.jwysiwyg.js'
}
}
var prep = {
engine: "node",
compiler: this.engine + " " + release.build_dir + "/uglify.js --unsafe",
post_compiler: this.engine + " " + release.build_dir + "/post-compile.js",
lint: "jsl"
}
task('build', ['prepare', 'package', 'minify', 'lint'], function() {
console.log('Building...');
});
task('package', ['prepare'], function() {
console.log('Package only a compiled version of the file.');
var src = fcts.compile().join('\n\n');
console.log('Compiling source...');
var copyright = fcts.createCopyright();
console.log('Adding copyright...');
var dist_path = path.normalize('./dist/' + release.version);
fs.mkdirSync(dist_path, 0755);
fs.writeFileSync(dist_path + '/' + release.output.standard, [copyright, src].join('\n\n'));
console.log('Done...');
});
task('minify', ['prepare', 'package'], function() {
});
task('lint', ['prepare', 'package'], function() {
});
task('clean', function() {
var dist_folder = path.normalize('./dist/' + release.version);
console.log('Cleaning dist folder.');
path.exists(dist_folder, function (exists) {
if (exists) fs.rmdirSync(dist_folder);
});
});
task('prepare', function() {
console.log('==> Set-up globals.')
console.log('Creating distribution path... ' + release.paths.dist);
fs.mkdir(release.paths.dist);
});
// Default task is the build task.
task('default', ['build']);
var fcts = {
compile: function() {
var _self = this,
oldSrc = release.files,
newSrc = [];
oldSrc.forEach(function(item) {
var filePath = path.normalize('./src/' + item + '.js'),
src = fs.readFileSync(filePath, 'utf8');
newSrc.push(_self.removeClosures(src));
});
return newSrc;
},
createCopyright: function() {
var copyrightFilePath = path.normalize('./build/copyright.txt'),
src = fs.readFileSync(copyrightFilePath, 'utf8');
return this.replaceTags(src);
},
removeClosures: function(src) {
src.replace(/\(\s?function\(\s?Wysiwyg\s?\)\s?\{\s?$/i, '');
src.replace(/\}\)\(\s?Wysiwyg\s?\);$/, '');
return src;
},
replaceTags: function(src) {
var dt = new Date();
src.replace('/@DATE/', dt.getFullYear().toString() + '-' + dt.getMonth().toString() + '-' + dt.getDay().toString())
src.replace('/@VERSION/', release.version);
return src;
}
};