Skip to content

Commit

Permalink
Update companion.ts
Browse files Browse the repository at this point in the history
Generalize OS filepaths
  • Loading branch information
Epic-Doughnut authored Jan 17, 2025
1 parent db6d83a commit 1e95da5
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions src/companion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,20 @@ export const submitKattisProblem = (problem: Problem) => {
globalThis.reporter.sendTelemetryEvent(telmetry.SUBMIT_TO_KATTIS);
const srcPath = problem.srcPath;
const homedir = os.homedir();
let submitPath = `${homedir}/.kattis/submit.py`;
if (process.platform == 'win32') {
if (
!existsSync(`${homedir}\\.kattis\\.kattisrc`) ||
!existsSync(`${homedir}\\.kattis\\submit.py`)
) {
vscode.window.showErrorMessage(
`Please ensure .kattisrc and submit.py are present in ${homedir}\\.kattis\\submit.py`,
);
return;
} else {
submitPath = `${homedir}\\.kattis\\submit.py`;
}
} else {
if (
!existsSync(`${homedir}/.kattis/.kattisrc`) ||
!existsSync(`${homedir}/.kattis/submit.py`)
) {
vscode.window.showErrorMessage(
`Please ensure .kattisrc and submit.py are present in ${homedir}/.kattis/submit.py`,
);
return;
} else {
submitPath = `${homedir}/.kattis/submit.py`;
}
const directoryChar = process.platform == 'win32' ? '\\' : '/';
let submitPath = `${homedir}${directoryChar}.kattis${directoryChar}submit.py`;

Check failure on line 32 in src/companion.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'submitPath' is never reassigned. Use 'const' instead

Check failure on line 33 in src/companion.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `····`
if (
!existsSync(`${homedir}${directoryChar}.kattis${directoryChar}.kattisrc`) ||

Check failure on line 35 in src/companion.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace ``${homedir}${directoryChar}.kattis${directoryChar}.kattisrc`` with `⏎············`${homedir}${directoryChar}.kattis${directoryChar}.kattisrc`,⏎········`
!existsSync(`${homedir}${directoryChar}.kattis${directoryChar}submit.py`)

Check failure on line 36 in src/companion.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace ``${homedir}${directoryChar}.kattis${directoryChar}submit.py`` with `⏎············`${homedir}${directoryChar}.kattis${directoryChar}submit.py`,⏎········`
) {
vscode.window.showErrorMessage(
`Please ensure .kattisrc and submit.py are present in ${homedir}${directoryChar}.kattis${directoryChar}`,
);
return;
}

Check failure on line 43 in src/companion.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Delete `········⏎····`

const pyshell = spawn('python', [submitPath, '-f', srcPath]);

//tells the python script to open submission window in new tab
Expand Down

0 comments on commit 1e95da5

Please sign in to comment.