@@ -13,13 +13,15 @@ struct RunScriptCommandPlugin: CommandPlugin {
1313 func performCommand( context: PackagePlugin . PluginContext , arguments: [ String ] ) async throws {
1414 try performCommand (
1515 packageDirectory: context. package . directory,
16+ workingDirectory: context. pluginWorkDirectory,
1617 tool: try context. tool ( named: " run-script-bin " ) ,
1718 arguments: arguments
1819 )
1920 }
2021
2122 private func performCommand(
2223 packageDirectory: Path ,
24+ workingDirectory: Path ,
2325 tool: PluginContext . Tool ,
2426 arguments: [ String ]
2527 ) throws {
@@ -36,10 +38,24 @@ struct RunScriptCommandPlugin: CommandPlugin {
3638 " --timing " ,
3739 timing
3840 ]
41+ process. environment = environments (
42+ packageDirectory: packageDirectory,
43+ workingDirectory: workingDirectory
44+ )
3945
4046 try process. run ( )
4147 process. waitUntilExit ( )
4248 }
49+
50+ private func environments(
51+ packageDirectory: Path ,
52+ workingDirectory: Path
53+ ) -> [ String : String ] {
54+ var environments = ProcessInfo . processInfo. environment
55+ environments [ " RUN_SCRIPT_TARGET_PACKAGE_DIR " ] = packageDirectory. string
56+ environments [ " RUN_SCRIPT_PLUGIN_WORK_DIR " ] = workingDirectory. string
57+ return environments
58+ }
4359}
4460
4561#if canImport(XcodeProjectPlugin)
@@ -49,6 +65,7 @@ extension RunScriptCommandPlugin: XcodeCommandPlugin {
4965 func performCommand( context: XcodeProjectPlugin . XcodePluginContext , arguments: [ String ] ) throws {
5066 try performCommand (
5167 packageDirectory: context. xcodeProject. directory,
68+ workingDirectory: context. pluginWorkDirectory,
5269 tool: try context. tool ( named: " run-script-bin " ) ,
5370 arguments: arguments
5471 )
0 commit comments