Skip to content

Commit 7fb3d07

Browse files
committed
Added a few altJS languages
1 parent 1b845b3 commit 7fb3d07

4 files changed

Lines changed: 23 additions & 18 deletions

File tree

src/ScriptCompiler/Compiler/CoffeeScript.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
class 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
}

src/ScriptCompiler/Compiler/LanguageCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
abstract 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();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

src/ScriptCompiler/ScriptCompiler.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)