parent
ed9c9d25e0
commit
feb5cb02b0
4 changed files with 26 additions and 32 deletions
|
@ -9,7 +9,6 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -19,16 +18,12 @@ jobs:
|
|||
with:
|
||||
tool_versions: |
|
||||
shellcheck 0.9.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: shellcheck scripts/*.sh
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: jdxcode/rtx-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# .tool-versions will be read from repo root
|
||||
- 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;
|
||||
async function setupRTX() {
|
||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
|
||||
const platform = `${getOS()}-${os.arch()}`;
|
||||
const rtxBinDir = path.join(rtxDir(), 'bin');
|
||||
const url = `https://rtx.pub/rtx-latest-${getOS()}-${os.arch()}`;
|
||||
await fs.promises.mkdir(rtxBinDir, { recursive: true });
|
||||
await exec.exec('gh', [
|
||||
'release',
|
||||
'download',
|
||||
'--clobber',
|
||||
'--pattern',
|
||||
`*${platform}`,
|
||||
'--repo',
|
||||
'jdxcode/rtx',
|
||||
'--output',
|
||||
path.join(rtxBinDir, 'rtx')
|
||||
]);
|
||||
await exec.exec('curl', [url, '--output', path.join(rtxBinDir, 'rtx')]);
|
||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
||||
core.addPath(rtxBinDir);
|
||||
}
|
||||
|
@ -91,6 +81,15 @@ async function getBinPaths() {
|
|||
const output = await exec.getExecOutput('rtx', ['bin-paths']);
|
||||
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')]) {
|
||||
try {
|
||||
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> {
|
||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
|
||||
const platform = `${getOS()}-${os.arch()}`
|
||||
const rtxBinDir = path.join(rtxDir(), 'bin')
|
||||
const url = `https://rtx.pub/rtx-latest-${getOS()}-${os.arch()}`
|
||||
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
||||
await exec.exec('gh', [
|
||||
'release',
|
||||
'download',
|
||||
'--clobber',
|
||||
'--pattern',
|
||||
`*${platform}`,
|
||||
'--repo',
|
||||
'jdxcode/rtx',
|
||||
'--output',
|
||||
path.join(rtxBinDir, 'rtx')
|
||||
])
|
||||
await exec.exec('curl', [url, '--output', path.join(rtxBinDir, 'rtx')])
|
||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
||||
core.addPath(rtxBinDir)
|
||||
}
|
||||
|
@ -64,6 +54,16 @@ async function getBinPaths(): Promise<string[]> {
|
|||
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) {
|
||||
try {
|
||||
run()
|
||||
|
|
Loading…
Add table
Reference in a new issue