forked from pattern-lab/patternlab-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder.php
More file actions
82 lines (61 loc) · 2.25 KB
/
builder.php
File metadata and controls
82 lines (61 loc) · 2.25 KB
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
<?php
/*!
* Pattern Lab Builder CLI - v0.6.1
*
* Copyright (c) 2013 Dave Olsen, http://dmolsen.com
* Licensed under the MIT license
*
* Usage:
*
* php builder.php -g
* Iterates over the 'source' directories & files and generates the entire site a single time.
* It also cleans the 'public' directory.
*
* php builder.php -w
* Generates the site like the -g flag and then watches for changes in the 'source' directories &
* files. Will re-generate files if they've changed.
*
*/
// load builder classes
require __DIR__."/lib/builder.lib.php";
require __DIR__."/lib/generator.lib.php";
require __DIR__."/lib/watcher.lib.php";
// load mustache & register it
require __DIR__."/lib/Mustache/Autoloader.php";
Mustache_Autoloader::register();
// load css rule saver
require __DIR__."/lib/css-rule-saver/css-rule-saver.php";
// make sure this script is being accessed from the command line
if (php_sapi_name() == 'cli') {
$args = getopt("gwc");
if (isset($args["g"])) {
// initiate the g (generate) switch
// iterate over the source directory and generate the site
$g = new Generatr();
// check to see if CSS for patterns should be parsed & outputted
(isset($args["c"])) ? $g->generate(true) : $g->generate();
print "your site has been generated...\n";
} else if (isset($args["w"])) {
// initiate the w (watch) switch
// iterate over the source directory and generate the site
$g = new Generatr();
$g->generate();
print "your site has been generated...\n";
// watch the source directory and regenerate any changed files
$w = new Watchr();
print "watching your site for changes...\n";
$w->watch();
} else {
// when in doubt write out the usage
print "\n";
print "Usage:\n\n";
print " php ".$_SERVER["PHP_SELF"]." -g\n";
print " Iterates over the 'source' directories & files and generates the entire site a single time.\n";
print " It also cleans the 'public' directory.\n\n";
print " php ".$_SERVER["PHP_SELF"]." -w\n";
print " Generates the site like the -g flag and then watches for changes in the 'source' directories &\n";
print " files. Will re-generate files if they've changed.\n\n";
}
} else {
print "The builder script can only be run from the command line.";
}