@@ -22,6 +22,7 @@ const io = __importStar(require("@actions/io"));
2222const path = __importStar ( require ( "path" ) ) ;
2323const exec_1 = require ( "@actions/exec" ) ;
2424const swift_versions_1 = require ( "./swift-versions" ) ;
25+ const get_version_1 = require ( "./get-version" ) ;
2526function install ( version , system ) {
2627 return __awaiter ( this , void 0 , void 0 , function * ( ) {
2728 const toolchainName = `swift ${ version } ` ;
@@ -49,27 +50,7 @@ function install(version, system) {
4950exports . install = install ;
5051function toolchainVersion ( requestedVersion ) {
5152 return __awaiter ( this , void 0 , void 0 , function * ( ) {
52- let output = '' ;
53- let error = '' ;
54- const options = {
55- listeners : {
56- stdout : ( data ) => {
57- output += data . toString ( ) ;
58- } ,
59- stderr : ( data ) => {
60- error += data . toString ( ) ;
61- }
62- }
63- } ;
64- yield exec_1 . exec ( 'xcrun' , [ '--toolchain' , requestedVersion , '--run' , 'swift' , '--version' ] , options ) ;
65- if ( error ) {
66- throw new Error ( error ) ;
67- }
68- const match = output . match ( / (?< version > [ 0 - 9 ] + \. [ 0 - 9 + ] + ( \. [ 0 - 9 ] + ) ? ) / ) || { groups : { version : null } } ;
69- if ( ! match . groups || ! match . groups . version ) {
70- return null ;
71- }
72- return match . groups . version ;
53+ return yield get_version_1 . getVersion ( 'xcrun' , [ '--toolchain' , requestedVersion , '--run' , 'swift' , '--version' ] ) ;
7354 } ) ;
7455}
7556function download ( { url } ) {
0 commit comments