diff options
Diffstat (limited to 'compiled.go')
-rw-r--r-- | compiled.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/compiled.go b/compiled.go new file mode 100644 index 0000000..5b2c19b --- /dev/null +++ b/compiled.go | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | |||
3 | This file is part of CompileTree (https://github.com/Pacien/CompileTree) | ||
4 | |||
5 | CompileTree is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU Affero General Public License as published by | ||
7 | the Free Software Foundation, either version 3 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | CompileTree is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with CompileTree. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | */ | ||
19 | |||
20 | package main | ||
21 | |||
22 | import ( | ||
23 | "fmt" | ||
24 | "os" | ||
25 | "time" | ||
26 | ) | ||
27 | |||
28 | func compiled(sourceDir, outputDir string) { | ||
29 | // remove previously compiled site | ||
30 | err := os.RemoveAll(outputDir) | ||
31 | if err != nil { | ||
32 | fmt.Println(err) | ||
33 | return | ||
34 | } | ||
35 | |||
36 | // compile everything | ||
37 | go compile(sourceDir, make(map[string][]byte), sourceDir, outputDir, true) | ||
38 | go copyFiles(sourceDir, sourceDir, outputDir, true) | ||
39 | |||
40 | // sleep some milliseconds to prevent early exit | ||
41 | time.Sleep(time.Millisecond * 100) | ||
42 | |||
43 | // wait until all tasks are completed | ||
44 | wait.Wait() | ||
45 | fmt.Println("Compilation done.") | ||
46 | } | ||