diff --git a/core/src/main/java/org/lflang/generator/LFGenerator.java b/core/src/main/java/org/lflang/generator/LFGenerator.java index 8ca19d67cf..f4e61e93d5 100644 --- a/core/src/main/java/org/lflang/generator/LFGenerator.java +++ b/core/src/main/java/org/lflang/generator/LFGenerator.java @@ -60,9 +60,7 @@ public static FileConfig createFileConfig( case Python -> new PyFileConfig(resource, srcGenBasePath, useHierarchicalBin); case CPP -> new CppFileConfig(resource, srcGenBasePath, useHierarchicalBin); case Rust -> new RustFileConfig(resource, srcGenBasePath, useHierarchicalBin); - // null is passed to the docker argument because it is up to the TS Generator to tell the - // FileConfig whether Docker is enabled - case TS -> new TSFileConfig(resource, srcGenBasePath, useHierarchicalBin, null); + case TS -> new TSFileConfig(resource, srcGenBasePath, useHierarchicalBin); }; } catch (IOException e) { throw new RuntimeException( diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt index 0d8e4e74ae..e04040f9b3 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt @@ -42,7 +42,7 @@ import java.nio.file.Path * @author Hokeun Kim */ class TSFileConfig( - resource: Resource, srcGenBasePath: Path, useHierarchicalBin: Boolean, var docker: Boolean? = null + resource: Resource, srcGenBasePath: Path, useHierarchicalBin: Boolean ) : FileConfig(resource, srcGenBasePath, useHierarchicalBin) { /** @@ -53,37 +53,4 @@ class TSFileConfig( super.doClean() FileUtil.deleteDirectory(srcGenPath) } - - fun setDocker(dockerEnabled: Boolean) { - docker = dockerEnabled - } - - override fun getCommand(): LFCommand { - if (docker == true) { - return super.getCommand() - } else if (docker == false) { - return LFCommand.get( - "node", - listOf(srcPkgPath.relativize(executable).toString()), - true, - srcPkgPath - ) - } else { - throw java.lang.IllegalStateException("The execute command cannot be determined because it is not known whether code generation is in Docker mode.") - } - } - - override fun getExecutableExtension(): String { - if (docker == true) { - return super.getExecutableExtension() - } - return ".js" - } - - override fun getExecutable(): Path { - if (docker == true) { - return super.getExecutable() - } - return srcGenPath.resolve("dist").resolve(name + executableExtension) - } } diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index ca7b9ec4e8..4fdcd9af01 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -112,7 +112,7 @@ class TSGenerator( override fun doGenerate(resource: Resource, context: LFGeneratorContext) { // Register the after delay transformation to be applied by GeneratorBase. registerTransformation(DelayedConnectionTransformation(TSDelayBodyGenerator, targetTypes, resource, true, true)) - fileConfig.setDocker(targetConfig.get(DockerProperty.INSTANCE).enabled) + super.doGenerate(resource, context) instantiationGraph @@ -453,7 +453,12 @@ class TSGenerator( context.finish(GeneratorResult.Status.COMPILED, codeMaps) val shScriptPath = fileConfig.binPath.resolve(fileConfig.name) val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js") - FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) + if (targetConfig.get(DockerProperty.INSTANCE).enabled) { + val launchScriptPath = context.fileConfig.srcPkgPath.relativize(fileConfig.binPath).toString() + FileUtil.writeToFile("#!/bin/sh\n $launchScriptPath", shScriptPath) + } else { + FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) + } shScriptPath.toFile().setExecutable(true) messageReporter.nowhere().info("Script for running the program: $shScriptPath.") }