@@ -30,8 +30,9 @@ function install(version, system) {
3030 let swiftPath = toolCache . find ( 'swift-macOS' , version ) ;
3131 if ( swiftPath === null || swiftPath . trim ( ) . length == 0 ) {
3232 core . debug ( `No matching installation found` ) ;
33- const path = yield download ( swift_versions_1 . swiftPackage ( version , system ) ) ;
34- const extracted = yield unpack ( path , version ) ;
33+ const pkg = swift_versions_1 . swiftPackage ( version , system ) ;
34+ const path = yield download ( pkg ) ;
35+ const extracted = yield unpack ( pkg , path , version ) ;
3536 swiftPath = extracted ;
3637 }
3738 else {
@@ -71,43 +72,17 @@ function toolchainVersion(requestedVersion) {
7172 return match . groups . version ;
7273 } ) ;
7374}
74- function setToolchainVersion ( requestedVersion ) {
75- return __awaiter ( this , void 0 , void 0 , function * ( ) {
76- let output = '' ;
77- let error = '' ;
78- const options = {
79- listeners : {
80- stdout : ( data ) => {
81- output += data . toString ( ) ;
82- } ,
83- stderr : ( data ) => {
84- error += data . toString ( ) ;
85- }
86- }
87- } ;
88- yield exec_1 . exec ( 'xcrun' , [ '--toolchain' , requestedVersion , '--run' , 'swift' , '--version' ] , options ) ;
89- if ( error ) {
90- throw new Error ( error ) ;
91- }
92- const match = output . match ( / (?< version > [ 0 - 9 ] + \. [ 0 - 9 + ] + ( \. [ 0 - 9 ] + ) ? ) / ) || { groups : { version : null } } ;
93- if ( ! match . groups || ! match . groups . version ) {
94- return null ;
95- }
96- return match . groups . version ;
97- } ) ;
98- }
9975function download ( { url } ) {
10076 return __awaiter ( this , void 0 , void 0 , function * ( ) {
10177 core . debug ( 'Downloading swift for macOS' ) ;
10278 return toolCache . downloadTool ( url ) ;
10379 } ) ;
10480}
105- function unpack ( packagePath , version ) {
81+ function unpack ( { name } , packagePath , version ) {
10682 return __awaiter ( this , void 0 , void 0 , function * ( ) {
10783 core . debug ( 'Extracting package' ) ;
10884 const unpackedPath = yield extractXar ( packagePath ) ;
109- yield exec_1 . exec ( 'ls' , [ '-las' , unpackedPath ] ) ;
110- const extractedPath = yield toolCache . extractTar ( path . join ( unpackedPath , 'Payload' ) ) ;
85+ const extractedPath = yield toolCache . extractTar ( path . join ( unpackedPath , name , 'Payload' ) ) ;
11186 core . debug ( 'Package extracted' ) ;
11287 const cachedPath = yield toolCache . cacheDir ( extractedPath , 'swift-macOS' , version ) ;
11388 core . debug ( 'Package cached' ) ;
0 commit comments