@@ -45,6 +45,7 @@ rescue NotImplementedError
4545end
4646
4747file 'dart-sass/sass' do
48+ raise # TODO: test-only, to remove
4849 gem_install 'sass-embedded' , SassConfig . gem_version , SassConfig . gem_platform do |installer |
4950 gh_attestation_verify ( installer . gem , repo : 'sass-contrib/sass-embedded-host-ruby' )
5051 mv File . absolute_path ( 'ext/sass/dart-sass' , installer . gem_dir ) , 'dart-sass'
@@ -289,19 +290,15 @@ end
289290# added to the FileUtils utility functions.
290291module FileUtils
291292 def unarchive ( archive , dest = '.' )
292- case archive . downcase
293- when -> ( name ) { name . include? ( '.tar.' ) || name . end_with? ( '.tar' ) }
294- mkdir_p dest
295- sh 'tar' , '-vxC' , dest , '-f' , archive , '--no-same-owner' , '--no-same-permissions'
296- when -> ( name ) { name . end_with? ( '.zip' ) }
297- if Gem . win_platform?
298- mkdir_p dest
299- sh File . absolute_path ( 'System32/tar.exe' , ENV . fetch ( 'SystemRoot' , 'C:/Windows' ) ) , '-vxC' , dest , '-f' , archive
300- else
293+ mkdir_p dest
294+ if Gem . win_platform?
295+ sh File . absolute_path ( 'tar.exe' , SassConfig . windows_get_folder_path ( :System ) ) , '-vxC' , dest , '-f' , archive
296+ else
297+ if archive . downcase . end_with? ( '.zip' )
301298 sh 'unzip' , '-od' , dest , archive
299+ else
300+ sh 'tar' , '-vxC' , dest , '-f' , archive , '--no-same-owner' , '--no-same-permissions'
302301 end
303- else
304- raise ArgumentError , "Unknown archive format #{ archive } "
305302 end
306303 end
307304
@@ -699,4 +696,19 @@ module SassConfig
699696 platform
700697 end
701698 end
699+
700+ def windows_get_folder_path ( folder )
701+ require 'open3'
702+
703+ stdout , stderr , status = Open3 . capture3 ( 'powershell' ,
704+ '-NoLogo' ,
705+ '-NoProfile' ,
706+ '-NonInteractive' ,
707+ '-Command' ,
708+ "[Environment]::GetFolderPath('#{ folder } ') | Write-Host -NoNewline" )
709+
710+ raise stderr unless status . success?
711+
712+ File . absolute_path ( stdout )
713+ end
702714end
0 commit comments