Skip to content

Commit a34e46f

Browse files
committed
Make sure plugins and specifications directories exist during install.
1 parent 6bf998f commit a34e46f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/macosMain/kotlin/co/touchlab/xcode/cli/LangSpecManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import co.touchlab.xcode.cli.util.Path
77
object LangSpecManager {
88
private val specName = "Kotlin.xclangspec"
99
private val specSourceFile = File(Path.dataDir / specName)
10-
private val specTargetFile = File(XcodeHelper.xcodeLibraryPath / "Specifications" / specName)
10+
private val specsDirectory = File(XcodeHelper.xcodeLibraryPath / "Specifications")
11+
private val specTargetFile = File(specsDirectory.path / specName)
1112
private val logger = Logger.withTag("LangSpecManager")
1213

1314
val isInstalled: Boolean
1415
get() = specTargetFile.exists()
1516

1617
fun install() {
1718
check(!specTargetFile.exists()) { "Language spec file exists at path ${specTargetFile.path}! Delete it first." }
19+
logger.v { "Ensuring language specification directory exists at ${specsDirectory.path}" }
20+
specsDirectory.mkdirs()
1821
logger.v { "Copying language specification to target path ${specTargetFile.path}" }
1922
specSourceFile.copy(specTargetFile.path)
2023
}

src/macosMain/kotlin/co/touchlab/xcode/cli/PluginManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import co.touchlab.xcode.cli.util.fromString
1111
object PluginManager {
1212
val pluginName = "Kotlin.ideplugin"
1313
val pluginSourceFile = File(Path.dataDir / pluginName)
14-
val pluginTargetFile = File(XcodeHelper.xcodeLibraryPath / "Plug-ins" / pluginName)
14+
val pluginsDirectory = File(XcodeHelper.xcodeLibraryPath / "Plug-ins")
15+
val pluginTargetFile = File(pluginsDirectory.path / pluginName)
1516

1617
private val pluginSourceInfoFile = File(pluginSourceFile.path / "Contents" / "Info.plist")
1718
private val pluginTargetInfoFile = File(pluginTargetFile.path / "Contents" / "Info.plist")
@@ -50,6 +51,8 @@ object PluginManager {
5051
}
5152

5253
fun install(xcodeInstallations: List<XcodeHelper.XcodeInstallation>) {
54+
logger.v { "Ensuring plugins directory exists at ${pluginsDirectory.path}" }
55+
pluginsDirectory.mkdirs()
5356
logger.v { "Copying Xcode plugin to target path ${pluginTargetFile.path}" }
5457
pluginSourceFile.copy(pluginTargetFile.path)
5558
sync(xcodeInstallations)

0 commit comments

Comments
 (0)