Hack around `rebar3` compiling your project to output its `version` (#256)

c36fc0c · Paulo F. Oliveira · 2024-03-03 23:49

2 files +38 -18

Files changed

modified dist/index.js
+19 −9
@@ -10562,8 +10562,9 @@ async function install(toolName, opts) {
10562 10562 reportVersion: () => {
10563 10563 const cmd = 'erl'
10564 10564 const args = ['-version']
10565 + const env = {}
10565 10566
10566 return [cmd, args]
10567 + return [cmd, args, env]
10567 10568 },
10568 10569 },
10569 10570 win32: {
@@ -10579,8 +10580,9 @@ async function install(toolName, opts) {
10579 10580 reportVersion: () => {
10580 10581 const cmd = 'erl.exe'
10581 10582 const args = ['+V']
10583 + const env = {}
10582 10584
10583 return [cmd, args]
10585 + return [cmd, args, env]
10584 10586 },
10585 10587 },
10586 10588 }
@@ -10608,8 +10610,9 @@ async function install(toolName, opts) {
10608 10610 reportVersion: () => {
10609 10611 const cmd = 'elixir'
10610 10612 const args = ['-v']
10613 + const env = {}
10611 10614
10612 return [cmd, args]
10615 + return [cmd, args, env]
10613 10616 },
10614 10617 },
10615 10618 }
@@ -10648,8 +10651,9 @@ async function install(toolName, opts) {
10648 10651 reportVersion: () => {
10649 10652 const cmd = 'gleam'
10650 10653 const args = ['--version']
10654 + const env = {}
10651 10655
10652 return [cmd, args]
10656 + return [cmd, args, env]
10653 10657 },
10654 10658 },
10655 10659 win32: {
@@ -10681,8 +10685,9 @@ async function install(toolName, opts) {
10681 10685 reportVersion: () => {
10682 10686 const cmd = 'gleam.exe'
10683 10687 const args = ['--version']
10688 + const env = {}
10684 10689
10685 return [cmd, args]
10690 + return [cmd, args, env]
10686 10691 },
10687 10692 },
10688 10693 }
@@ -10713,8 +10718,12 @@ async function install(toolName, opts) {
10713 10718 reportVersion: () => {
10714 10719 const cmd = 'rebar3'
10715 10720 const args = ['version']
10721 + const env = {
10722 + REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
10723 + REBAR_CONFIG: 'fake.config',
10724 + }
10716 10725
10717 return [cmd, args]
10726 + return [cmd, args, env]
10718 10727 },
10719 10728 },
10720 10729 win32: {
@@ -10749,8 +10758,9 @@ async function install(toolName, opts) {
10749 10758 reportVersion: () => {
10750 10759 const cmd = 'rebar3.cmd'
10751 10760 const args = ['version']
10761 + const env = {}
10752 10762
10753 return [cmd, args]
10763 + return [cmd, args, env]
10754 10764 },
10755 10765 },
10756 10766 }
@@ -10804,8 +10814,8 @@ async function installTool(opts) {
10804 10814 core.exportVariable(installDirForVarName, runnerToolPath)
10805 10815
10806 10816 core.info(`Installed ${installOpts.tool} version`)
10807 const [cmd, args] = platformOpts.reportVersion()
10808 await exec(cmd, args)
10817 + const [cmd, args, env] = platformOpts.reportVersion()
10818 + await exec(cmd, args, { env: { ...process.env, ...env } })
10809 10819 }
10810 10820
10811 10821 function checkPlatform() {
modified src/setup-beam.js
+19 −9
@@ -731,8 +731,9 @@ async function install(toolName, opts) {
731 731 reportVersion: () => {
732 732 const cmd = 'erl'
733 733 const args = ['-version']
734 + const env = {}
734 735
735 return [cmd, args]
736 + return [cmd, args, env]
736 737 },
737 738 },
738 739 win32: {
@@ -748,8 +749,9 @@ async function install(toolName, opts) {
748 749 reportVersion: () => {
749 750 const cmd = 'erl.exe'
750 751 const args = ['+V']
752 + const env = {}
751 753
752 return [cmd, args]
754 + return [cmd, args, env]
753 755 },
754 756 },
755 757 }
@@ -777,8 +779,9 @@ async function install(toolName, opts) {
777 779 reportVersion: () => {
778 780 const cmd = 'elixir'
779 781 const args = ['-v']
782 + const env = {}
780 783
781 return [cmd, args]
784 + return [cmd, args, env]
782 785 },
783 786 },
784 787 }
@@ -817,8 +820,9 @@ async function install(toolName, opts) {
817 820 reportVersion: () => {
818 821 const cmd = 'gleam'
819 822 const args = ['--version']
823 + const env = {}
820 824
821 return [cmd, args]
825 + return [cmd, args, env]
822 826 },
823 827 },
824 828 win32: {
@@ -850,8 +854,9 @@ async function install(toolName, opts) {
850 854 reportVersion: () => {
851 855 const cmd = 'gleam.exe'
852 856 const args = ['--version']
857 + const env = {}
853 858
854 return [cmd, args]
859 + return [cmd, args, env]
855 860 },
856 861 },
857 862 }
@@ -882,8 +887,12 @@ async function install(toolName, opts) {
882 887 reportVersion: () => {
883 888 const cmd = 'rebar3'
884 889 const args = ['version']
890 + const env = {
891 + REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
892 + REBAR_CONFIG: 'fake.config',
893 + }
885 894
886 return [cmd, args]
895 + return [cmd, args, env]
887 896 },
888 897 },
889 898 win32: {
@@ -918,8 +927,9 @@ async function install(toolName, opts) {
918 927 reportVersion: () => {
919 928 const cmd = 'rebar3.cmd'
920 929 const args = ['version']
930 + const env = {}
921 931
922 return [cmd, args]
932 + return [cmd, args, env]
923 933 },
924 934 },
925 935 }
@@ -973,8 +983,8 @@ async function installTool(opts) {
973 983 core.exportVariable(installDirForVarName, runnerToolPath)
974 984
975 985 core.info(`Installed ${installOpts.tool} version`)
976 const [cmd, args] = platformOpts.reportVersion()
977 await exec(cmd, args)
986 + const [cmd, args, env] = platformOpts.reportVersion()
987 + await exec(cmd, args, { env: { ...process.env, ...env } })
978 988 }
979 989
980 990 function checkPlatform() {

Parents: 7c4882b