@@ -612,16 +612,13 @@ module SassConfig
612
612
613
613
def embedded_sass_protocol
614
614
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' )
621
615
622
- raise stderr unless status . success?
616
+ version = Utils . capture ( RbConfig . ruby ,
617
+ File . absolute_path ( '../../exe/sass' , __dir__ ) ,
618
+ '--embedded' ,
619
+ '--version' )
623
620
624
- tag_name = JSON . parse ( stdout ) [ 'protocolVersion' ]
621
+ tag_name = JSON . parse ( version ) [ 'protocolVersion' ]
625
622
626
623
"https://github.com/sass/sass/raw/embedded-protocol-#{ tag_name } /spec/embedded_sass.proto"
627
624
rescue StandardError # TODO: remove after https://github.com/sass/dart-sass/pull/2413
671
668
module Utils
672
669
module_function
673
670
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
+
674
681
def fetch_https ( source_uri )
675
682
require 'rubygems/remote_fetcher'
676
683
@@ -684,19 +691,13 @@ module Utils
684
691
end
685
692
686
693
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 )
701
702
end
702
703
end
0 commit comments