Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File extension of TypeScript launch script adjusted on Windows #2427

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package org.lflang.generator.ts

import org.eclipse.emf.ecore.resource.Resource
import org.lflang.FileConfig
import org.lflang.generator.GeneratorUtils
import org.lflang.util.FileUtil
import org.lflang.util.LFCommand
import java.io.IOException
Expand All @@ -53,4 +54,8 @@ class TSFileConfig(
super.doClean()
FileUtil.deleteDirectory(srcGenPath)
}

override fun getExecutableExtension(): String {
return if (GeneratorUtils.isHostWindows()) ".bat" else ""
}
}
3 changes: 2 additions & 1 deletion core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import org.lflang.util.FileUtil
import java.nio.file.Files
import java.nio.file.Path
import java.util.*
import kotlin.io.path.extension

private const val NO_NPM_MESSAGE = "The TypeScript target requires npm >= 6.14.4. " +
"For installation instructions, see: https://www.npmjs.com/get-npm. \n" +
Expand Down Expand Up @@ -451,7 +452,7 @@ class TSGenerator(
context.unsuccessfulFinish()
} else {
context.finish(GeneratorResult.Status.COMPILED, codeMaps)
val shScriptPath = fileConfig.binPath.resolve(fileConfig.name)
val shScriptPath = fileConfig.executable
val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js")
FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath)
shScriptPath.toFile().setExecutable(true)
Expand Down
Loading