@@ -9,28 +9,27 @@ const rubyBuilderVersions = require('./ruby-builder-versions')
99const builderReleaseTag = 'enable-shared'
1010const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
1111
12- const isWin = ( os . platform ( ) === 'win32' )
12+ const windows = common . windows
1313
1414export function getAvailableVersions ( platform , engine ) {
1515 return rubyBuilderVersions . getVersions ( platform ) [ engine ]
1616}
1717
1818export async function install ( platform , engine , version ) {
19- const rubyPrefix = await downloadAndExtract ( platform , engine , version )
20- return rubyPrefix
19+ return await downloadAndExtract ( platform , engine , version )
2120}
2221
2322async function downloadAndExtract ( platform , engine , version ) {
24- const rubiesDir = isWin ?
25- `${ ( process . env . GITHUB_WORKSPACE || 'C' ) [ 0 ] } :` :
26- path . join ( os . homedir ( ) , '.rubies' )
23+ const rubiesDir = windows ? `${ common . drive } :` : path . join ( os . homedir ( ) , '.rubies' )
2724
2825 const rubyPrefix = path . join ( rubiesDir , `${ engine } -${ version } ` )
29- const newPathEntries = ( engine === 'rubinius' ) ?
30- [ path . join ( rubyPrefix , 'bin' ) , path . join ( rubyPrefix , 'gems' , 'bin' ) ] :
31- [ path . join ( rubyPrefix , 'bin' ) ]
3226
33- common . setupPath ( newPathEntries )
27+ // Set the PATH now, so the MSYS2 'tar' is in Path on Windows
28+ if ( engine === 'rubinius' ) {
29+ common . setupPath ( [ path . join ( rubyPrefix , 'bin' ) , path . join ( rubyPrefix , 'gems' , 'bin' ) ] )
30+ } else {
31+ common . setupPath ( [ path . join ( rubyPrefix , 'bin' ) ] )
32+ }
3433
3534 await io . mkdirP ( rubiesDir )
3635
@@ -41,8 +40,8 @@ async function downloadAndExtract(platform, engine, version) {
4140 } )
4241
4342 await common . measure ( 'Extracting Ruby' , async ( ) => {
44- // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
45- if ( isWin ) {
43+ if ( windows ) {
44+ // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
4645 await exec . exec ( 'tar' , [ '-xz' , '-C' , common . win2nix ( rubiesDir ) , '-f' , common . win2nix ( downloadPath ) ] )
4746 } else {
4847 await exec . exec ( 'tar' , [ '-xz' , '-C' , rubiesDir , '-f' , downloadPath ] )
0 commit comments