Skip to content

Commit 86a5de1

Browse files
committed
Test
1 parent 3b3786a commit 86a5de1

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

ext/sass/Rakefile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ rescue NotImplementedError
4545
end
4646

4747
file '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,13 @@ end
289290
# added to the FileUtils utility functions.
290291
module 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
301-
sh 'unzip', '-od', dest, archive
302-
end
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+
elsif archive.downcase.end_with?('.zip')
297+
sh 'unzip', '-od', dest, archive
303298
else
304-
raise ArgumentError, "Unknown archive format #{archive}"
299+
sh 'tar', '-vxC', dest, '-f', archive, '--no-same-owner', '--no-same-permissions'
305300
end
306301
end
307302

@@ -699,4 +694,19 @@ module SassConfig
699694
platform
700695
end
701696
end
697+
698+
def windows_get_folder_path(folder)
699+
require 'open3'
700+
701+
stdout, stderr, status = Open3.capture3('powershell',
702+
'-NoLogo',
703+
'-NoProfile',
704+
'-NonInteractive',
705+
'-Command',
706+
"[Environment]::GetFolderPath('#{folder}') | Write-Host -NoNewline")
707+
708+
raise stderr unless status.success?
709+
710+
File.absolute_path(stdout)
711+
end
702712
end

0 commit comments

Comments
 (0)