Skip to content

Commit 6d13553

Browse files
authored
Update Rakefile
1 parent 8411a4c commit 6d13553

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

ext/sass/Rakefile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,13 @@ module SassConfig
612612

613613
def embedded_sass_protocol
614614
require 'json'
615-
require 'open3'
616-
617-
stdout, stderr, status = Open3.capture3(RbConfig.ruby,
618-
File.absolute_path('../../exe/sass', __dir__),
619-
'--embedded',
620-
'--version')
621615

622-
raise stderr unless status.success?
616+
version = Utils.capture(RbConfig.ruby,
617+
File.absolute_path('../../exe/sass', __dir__),
618+
'--embedded',
619+
'--version')
623620

624-
tag_name = JSON.parse(stdout)['protocolVersion']
621+
tag_name = JSON.parse(version)['protocolVersion']
625622

626623
"https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
627624
rescue StandardError # TODO: remove after https://github.com/sass/dart-sass/pull/2413
@@ -671,6 +668,16 @@ end
671668
module Utils
672669
module_function
673670

671+
def capture(...)
672+
require 'open3'
673+
674+
stdout, stderr, status = Open3.capture3(...)
675+
676+
raise stderr unless status.success?
677+
678+
stdout
679+
end
680+
674681
def fetch_https(source_uri)
675682
require 'rubygems/remote_fetcher'
676683

@@ -684,19 +691,13 @@ module Utils
684691
end
685692

686693
def windows_system_directory
687-
require 'open3'
688-
689-
stdout, stderr, status = Open3.capture3(
690-
'powershell.exe',
691-
'-NoLogo',
692-
'-NoProfile',
693-
'-NonInteractive',
694-
'-Command',
695-
'[Environment]::GetFolderPath([Environment+SpecialFolder]::System) | Write-Host -NoNewline'
696-
)
697-
698-
raise stderr unless status.success?
699-
700-
File.absolute_path(stdout)
694+
path = capture('powershell.exe',
695+
'-NoLogo',
696+
'-NoProfile',
697+
'-NonInteractive',
698+
'-Command',
699+
'[Environment]::GetFolderPath([Environment+SpecialFolder]::System) | Write-Host -NoNewline')
700+
701+
File.absolute_path(path)
701702
end
702703
end

0 commit comments

Comments
 (0)