parent
ed9c9d25e0
commit
feb5cb02b0
4 changed files with 26 additions and 32 deletions
|
@ -9,7 +9,6 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -19,16 +18,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
tool_versions: |
|
tool_versions: |
|
||||||
shellcheck 0.9.0
|
shellcheck 0.9.0
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- run: shellcheck scripts/*.sh
|
- run: shellcheck scripts/*.sh
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: jdxcode/rtx-action@v1
|
- uses: jdxcode/rtx-action@v1
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# .tool-versions will be read from repo root
|
# .tool-versions will be read from repo root
|
||||||
- run: node ./my_app.js
|
- run: node ./my_app.js
|
||||||
```
|
```
|
||||||
|
|
25
dist/index.js
generated
vendored
25
dist/index.js
generated
vendored
|
@ -46,20 +46,10 @@ async function run() {
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
async function setupRTX() {
|
async function setupRTX() {
|
||||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
|
const rtxBinDir = path.join(rtxDir(), 'bin');
|
||||||
const platform = `${getOS()}-${os.arch()}`;
|
const url = `https://rtx.pub/rtx-latest-${getOS()}-${os.arch()}`;
|
||||||
await fs.promises.mkdir(rtxBinDir, { recursive: true });
|
await fs.promises.mkdir(rtxBinDir, { recursive: true });
|
||||||
await exec.exec('gh', [
|
await exec.exec('curl', [url, '--output', path.join(rtxBinDir, 'rtx')]);
|
||||||
'release',
|
|
||||||
'download',
|
|
||||||
'--clobber',
|
|
||||||
'--pattern',
|
|
||||||
`*${platform}`,
|
|
||||||
'--repo',
|
|
||||||
'jdxcode/rtx',
|
|
||||||
'--output',
|
|
||||||
path.join(rtxBinDir, 'rtx')
|
|
||||||
]);
|
|
||||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
||||||
core.addPath(rtxBinDir);
|
core.addPath(rtxBinDir);
|
||||||
}
|
}
|
||||||
|
@ -91,6 +81,15 @@ async function getBinPaths() {
|
||||||
const output = await exec.getExecOutput('rtx', ['bin-paths']);
|
const output = await exec.getExecOutput('rtx', ['bin-paths']);
|
||||||
return output.stdout.split('\n');
|
return output.stdout.split('\n');
|
||||||
}
|
}
|
||||||
|
function rtxDir() {
|
||||||
|
if (process.env.RTX_DATA_HOME) {
|
||||||
|
return process.env.RTX_DATA_HOME;
|
||||||
|
}
|
||||||
|
if (process.env.XDG_DATA_HOME) {
|
||||||
|
return path.join(process.env.XDG_DATA_HOME, 'rtx');
|
||||||
|
}
|
||||||
|
return path.join(os.homedir(), '.local/share/rtx');
|
||||||
|
}
|
||||||
if (require.main === require.cache[eval('__filename')]) {
|
if (require.main === require.cache[eval('__filename')]) {
|
||||||
try {
|
try {
|
||||||
run();
|
run();
|
||||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
26
src/main.ts
26
src/main.ts
|
@ -14,20 +14,10 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupRTX(): Promise<void> {
|
async function setupRTX(): Promise<void> {
|
||||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
|
const rtxBinDir = path.join(rtxDir(), 'bin')
|
||||||
const platform = `${getOS()}-${os.arch()}`
|
const url = `https://rtx.pub/rtx-latest-${getOS()}-${os.arch()}`
|
||||||
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
||||||
await exec.exec('gh', [
|
await exec.exec('curl', [url, '--output', path.join(rtxBinDir, 'rtx')])
|
||||||
'release',
|
|
||||||
'download',
|
|
||||||
'--clobber',
|
|
||||||
'--pattern',
|
|
||||||
`*${platform}`,
|
|
||||||
'--repo',
|
|
||||||
'jdxcode/rtx',
|
|
||||||
'--output',
|
|
||||||
path.join(rtxBinDir, 'rtx')
|
|
||||||
])
|
|
||||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
||||||
core.addPath(rtxBinDir)
|
core.addPath(rtxBinDir)
|
||||||
}
|
}
|
||||||
|
@ -64,6 +54,16 @@ async function getBinPaths(): Promise<string[]> {
|
||||||
return output.stdout.split('\n')
|
return output.stdout.split('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rtxDir(): string {
|
||||||
|
if (process.env.RTX_DATA_HOME) {
|
||||||
|
return process.env.RTX_DATA_HOME
|
||||||
|
}
|
||||||
|
if (process.env.XDG_DATA_HOME) {
|
||||||
|
return path.join(process.env.XDG_DATA_HOME, 'rtx')
|
||||||
|
}
|
||||||
|
return path.join(os.homedir(), '.local/share/rtx')
|
||||||
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
try {
|
try {
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Add table
Reference in a new issue