Skip to content

Commit

Permalink
Cleanup some useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
d2c7727d4668 committed Jul 8, 2024
1 parent a94c151 commit 388bf25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { getLanguage, ocHide, ocShow, ocWrite } from './utils';
import {
getLanguage,
getWorkspaceRoot,
ocHide,
ocShow,
ocWrite,
} from './utils';
import { Language } from './types';
import { spawn } from 'child_process';
import path from 'path';
import {
getSaveLocationPref,
getHideStderrorWhenCompiledOK,
getWorkspaceModePref,
} from './preferences';
import * as vscode from 'vscode';
import { getJudgeViewProvider } from './extension';
Expand All @@ -32,12 +37,12 @@ export const getBinSaveLocation = (srcPath: string): string => {
}
const ext = language.name == 'java' ? '*.class' : '.bin';
const savePreference = getSaveLocationPref();
const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
const workspaceRoot = getWorkspaceRoot();
const srcFileName = path.parse(srcPath).name;
const binFileName = srcFileName + ext;
const binDir = path.dirname(srcPath);
if (getWorkspaceModePref() && workspaceFolder) {
return path.join(workspaceFolder, '.cph', binFileName);
if (workspaceRoot) {
return path.join(workspaceRoot, '.cph', binFileName);
} else if (savePreference && savePreference !== '') {
return path.join(savePreference, binFileName);
}
Expand Down
8 changes: 3 additions & 5 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,14 @@ export const saveProblem = (srcPath: string, problem: Problem) => {
const srcFolder = path.dirname(srcPath);
const cphFolder = path.join(srcFolder, '.cph');
const workspaceRoot = getWorkspaceRoot();
let probFolder: string;

if (workspaceRoot) {
probFolder = path.join(workspaceRoot, '.cph');
if (!fs.existsSync(probFolder)) {
const workspaceCphFolder = path.join(workspaceRoot, '.cph');
if (!fs.existsSync(workspaceCphFolder)) {
console.log('Making workspaceRoot/.cph folder');
fs.mkdirSync(probFolder);
fs.mkdirSync(workspaceCphFolder);
}
} else if (getSaveLocationPref() === '' && !fs.existsSync(cphFolder)) {
probFolder = cphFolder;
console.log('Making .cph folder');
fs.mkdirSync(cphFolder);
}
Expand Down

0 comments on commit 388bf25

Please sign in to comment.