Search in sources :

Example 1 with CoffeeScriptCompileDestinationCalculator

use of org.gradle.plugins.javascript.coffeescript.compile.internal.CoffeeScriptCompileDestinationCalculator in project gradle by gradle.

the class CoffeeScriptCompilerWorker method process.

public void process(SerializableCoffeeScriptCompileSpec spec) {
    Scriptable coffeeScriptScope = parse(spec.getCoffeeScriptJs(), "UTF-8", new Action<Context>() {

        public void execute(Context context) {
            context.setOptimizationLevel(-1);
        }
    });
    String encoding = spec.getOptions().getEncoding();
    CoffeeScriptCompileDestinationCalculator destinationCalculator = new CoffeeScriptCompileDestinationCalculator(spec.getDestinationDir());
    for (RelativeFile target : spec.getSource()) {
        String source = readFile(target.getFile(), encoding);
        String output = compile(coffeeScriptScope, source, target.getRelativePath().getPathString());
        writeFile(output, destinationCalculator.transform(target.getRelativePath()), encoding);
    }
}
Also used : Context(org.mozilla.javascript.Context) CoffeeScriptCompileDestinationCalculator(org.gradle.plugins.javascript.coffeescript.compile.internal.CoffeeScriptCompileDestinationCalculator) RelativeFile(org.gradle.api.internal.file.RelativeFile) Scriptable(org.mozilla.javascript.Scriptable)

Aggregations

RelativeFile (org.gradle.api.internal.file.RelativeFile)1 CoffeeScriptCompileDestinationCalculator (org.gradle.plugins.javascript.coffeescript.compile.internal.CoffeeScriptCompileDestinationCalculator)1 Context (org.mozilla.javascript.Context)1 Scriptable (org.mozilla.javascript.Scriptable)1