Skip to content

Commit

Permalink
fix: check for both with and without path.dirname (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Dec 9, 2023
1 parent d073c19 commit 6e9f49e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path = require('path');
import { Tab, TabInputCustom, TabInputNotebook, TabInputText, window, workspace } from 'vscode';
import Task, { File } from './Task';
import fs = require('fs');

/**
* Returns an empty task structure.
Expand Down Expand Up @@ -91,5 +92,9 @@ export function getFilePath(file: File) {
if (!file.workspaceFolder) return file.relativePath;
const workspacePath = getWorkspaceFolderFromName(file.workspaceFolder)?.uri.fsPath;
if (!workspacePath) return null;
return path.join(path.dirname(workspacePath), file.relativePath);
let filePath = path.join(workspacePath, file.relativePath);
if (fs.existsSync(filePath)) return filePath;
filePath = path.join(path.dirname(workspacePath), file.relativePath);
if (fs.existsSync(filePath)) return filePath;
return null;
}

0 comments on commit 6e9f49e

Please sign in to comment.