File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ import BridgeJSCore
2020import BridgeJSSkeleton
2121#endif
2222
23+ #if os(Windows)
24+ let PATH_SEPARATOR : Character = " ; "
25+ #else
26+ let PATH_SEPARATOR : Character = " : "
27+ #endif
28+
2329internal func which(
2430 _ executable: String ,
2531 environment: [ String : String ] = ProcessInfo . processInfo. environment
@@ -39,13 +45,8 @@ internal func which(
3945 }
4046 }
4147 }
42- let pathSeparator : Character
43- #if os(Windows)
44- pathSeparator = " ; "
45- #else
46- pathSeparator = " : "
47- #endif
48- let paths = environment [ " PATH " ] ? . split ( separator: pathSeparator) ?? [ ]
48+
49+ let paths = environment [ " PATH " ] ? . split ( separator: PATH_SEPARATOR) ?? [ ]
4950 for path in paths {
5051 let url = URL ( fileURLWithPath: String ( path) ) . appendingPathComponent ( executable)
5152 if checkCandidate ( url) {
Original file line number Diff line number Diff line change 11import Foundation
22import Testing
3+ @testable import TS2Swift
34
45/// Runs the TS2Swift JavaScript test suite (Vitest) so that `swift test --package-path ./Plugins/BridgeJS`
56/// validates both the TypeScript ts2swift output and the Swift codegen. For fast iteration on ts2swift,
@@ -17,8 +18,16 @@ import Testing
1718 . appendingPathComponent ( " TS2Swift " )
1819 . appendingPathComponent ( " JavaScript " )
1920 let process = Process ( )
20- process. executableURL = URL ( fileURLWithPath: " /usr/bin/env " )
21- var arguments = [ " npm " , " run " , " test " ]
21+ guard let npmExecutable = which ( " npm " ) , let nodeExecutable = which ( " node " ) else {
22+ Issue . record ( " No \" npm \" command found in your system " )
23+ return
24+ }
25+ process. executableURL = npmExecutable
26+ var environment = ProcessInfo . processInfo. environment
27+ environment [ " PATH " ] =
28+ " \( nodeExecutable. deletingLastPathComponent ( ) . path) \( PATH_SEPARATOR) \( environment [ " PATH " ] ?? " " ) "
29+ process. environment = environment
30+ var arguments = [ " run " , " test " ]
2231 if ProcessInfo . processInfo. environment [ " UPDATE_SNAPSHOTS " ] != nil {
2332 arguments. append ( contentsOf: [ " -- " , " --update " ] )
2433 }
You can’t perform that action at this time.
0 commit comments