forked from soldair/node-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
43 lines (40 loc) · 1.07 KB
/
build.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
var spawn = require('child_process').spawn,
fs = require('fs');
var q = [
function(){
var browserify = spawn('node',['node_modules/browserify/bin/cmd.js','qrcodeclient.js','-o', 'build/qrcode.js']);
browserify.stdin.end();
browserify.stdout.pipe(process.stdout);
browserify.stderr.pipe(process.stderr);
browserify.on('exit',function(code){
if(code){
console.error('browserify failed!');
process.exit(code);
}
done();
});
},
function(){
var uglify = spawn('node',['node_modules/uglify-js/bin/uglifyjs','build/qrcode.js']);
var minStream = fs.createWriteStream('build/qrcode.min.js');
uglify.stdout.pipe(minStream);
uglify.stdin.end();
uglify.on('exit',function(code){
if(code){
console.error('uglify failed!');
fs.unlink('build/qrcode.min.js',function(){
process.exit(code);
});
}
done();
});
}
],done = function(){
var j = q.shift();
if(j) j();
else complete()
},
complete = function(){
console.log('build complete =)');
};
done();