File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77class CoffeeScript extends LanguageCompiler {
88 protected $ baseLanguage = "js " ;
9- protected $ defaults = array (
10- );
119
1210 public function compile (Resource $ resource ) {
13- throw new \Exception ("Implement this! " );
11+ $ command = "coffee --compile {$ resource ->path } {$ this ->flags } --output {$ resource ->hash }" ;
12+ $ this ->execute ($ command );
1413 }
1514
1615}
Original file line number Diff line number Diff line change 99
1010abstract class LanguageCompiler {
1111 protected $ baseLanguage ;
12- protected $ defaults ;
12+ protected $ defaults = array () ;
1313 protected $ options ;
14- protected $ flags ;
14+ protected $ flags = '' ;
1515
1616 public function __construct () {
1717 $ this ->newestTime = time ();
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ScriptCompiler \Compiler ;
4+
5+ use ScriptCompiler \Resource ;
6+
7+ class TypeScript extends LanguageCompiler {
8+ protected $ baseLanguage = "js " ;
9+ protected $ defaults = array (
10+ "removeComments "
11+ );
12+
13+ public function compile (Resource $ resource ) {
14+ $ command = "tsc {$ this ->flags } --out {$ resource ->hash } {$ resource ->path }" ;
15+ $ this ->execute ($ command );
16+ }
17+
18+ }
Original file line number Diff line number Diff line change @@ -45,18 +45,6 @@ protected function mergeConfigs($config) {
4545 throw new \Exception ("Configuration must be an array " );
4646 }
4747
48- /*
49- Implement the following:
50-
51- https://www.dartlang.org
52- coffeescript.org
53- ckknight.github.io/gorillascript/
54- www.typescriptlang.org
55- www.cappuccino-project.org/learn/objective-j.html
56- rubyjs.org/index.html
57-
58- */
59-
6048 $ dc = $ _SERVER ['DOCUMENT_ROOT ' ];
6149 $ defaults = array (
6250 "doc_root " => $ dc ,
@@ -68,7 +56,7 @@ protected function mergeConfigs($config) {
6856 'scss ' => 'ScriptCompiler\Compiler\Sass ' ,
6957 'less ' => 'ScriptCompiler\Compiler\Less ' ,
7058 'js ' => 'ScriptCompiler\Compiler\UglifyJs2 ' ,
71- 'cs ' => 'ScriptCompiler\Compiler\CoffeeScript ' ,
59+ 'coffee ' => 'ScriptCompiler\Compiler\CoffeeScript ' ,
7260 )
7361 );
7462 return $ this ->mergeRecursive ($ defaults , $ config );
You can’t perform that action at this time.
0 commit comments