UNPKG

1.44 kBJavaScriptView Raw
1var Execute = require('child_process').exec
2var Prompt = require('prompt');
3
4var examples = [
5 [
6 "01-hello-world/",
7 "hello-world.js",
8 "Hello World"
9 ],
10 [
11 "02-fog/",
12 "fog.js",
13 "Fog Augment"
14 ],
15 [
16 "03-normal-colors/",
17 "normal-colors.js",
18 "Normal Colors Augment"
19 ]
20]
21
22examples.forEach(function(example) {
23
24 var source = "examples/" + example[0]
25 var target = "gh-pages/" + source
26 var file = example[1]
27 var name = example[2]
28
29 Execute( "mkdir -p "+target )
30
31 browseriyFiles( source, target, file )
32 outputIndexHtml( target, name )
33})
34
35function browseriyFiles( source, target, file ) {
36
37 var command = [
38 "browserify ", source, file,
39 " --debug",
40 " -t [ babelify --presets [ es2015 ] ]",
41 " -t brfs -t glslify",
42 " -g uglifyify",
43 " | exorcist ", target, "bundle.js.map > ", target, "bundle.js"
44 ].join("")
45
46 console.log(command)
47 var process = Execute( command )
48 process.stdout.pipe(process.stdout)
49}
50
51function outputIndexHtml( destination, name ) {
52 var html = [
53 "<!DOCTYPE html>",
54 "<html>",
55 "<head>",
56 " <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>",
57 " <meta name='viewport' content='width=device-width, initial-scale=1' />",
58 " <title>"+name+" | Glam</title>",
59 "</head>",
60 "<body>",
61 " <script src='bundle.js' type='text/javascript' charset='utf-8'></script>",
62 "</body>",
63 "</html>",
64 ].join("\n")
65
66 require('fs').writeFile( destination + "index.html", html )
67}
\No newline at end of file