diff --git a/src/fs/filesystem.ts b/src/fs/filesystem.ts index e1b524a..280eed5 100644 --- a/src/fs/filesystem.ts +++ b/src/fs/filesystem.ts @@ -14,7 +14,6 @@ export const getParentDir = (path: string) => { let d = path.split('/').slice(0, -1).join('/'); return d === '' ? (path.startsWith('/') ? '/' : '.') : d; } -export const getFileName = (path: string) => path.split('/').splice(-1)[0]; export function readDirAsArray(fs: FS, path: string): Promise { return new Promise((res, rej) => fs.readdir(path, (err, files) => err ? rej(err) : res(files))); diff --git a/src/runner/actions.ts b/src/runner/actions.ts index 18de1e7..c9b8f3d 100644 --- a/src/runner/actions.ts +++ b/src/runner/actions.ts @@ -1,7 +1,7 @@ // Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING. import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -import { getFileName, getParentDir } from '../fs/filesystem'; +import { getParentDir } from '../fs/filesystem'; import { spawnOpenSCAD } from "./openscad-runner"; import { processMergedOutputs } from "./output-parser"; import { AbortablePromise, turnIntoDelayableExecution } from '../utils'; @@ -14,7 +14,6 @@ export const checkSyntax = // const timestamp = Date.now(); source = '$preview=true;\n' + source; - sourcePath = getFileName(sourcePath); const job = spawnOpenSCAD({ inputs: [[sourcePath, source + '\n']], @@ -58,7 +57,6 @@ export const render = prefixLines.push('$preview=true;'); } source = [...prefixLines, source].join('\n'); - sourcePath = getFileName(sourcePath); const args = [ sourcePath, diff --git a/src/runner/output-parser.ts b/src/runner/output-parser.ts index 494e91d..6fc273c 100644 --- a/src/runner/output-parser.ts +++ b/src/runner/output-parser.ts @@ -1,5 +1,4 @@ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -import { getFileName } from '../fs/filesystem'; import { MergedOutputs } from "./openscad-worker"; const ignoredLogs = new Set([ @@ -45,10 +44,10 @@ export function parseMergedOutputs(mergedOutputs: MergedOutputs, opts: MergedOut severity: monaco.MarkerSeverity.Error }) } - const shiftSourceName = opts.shiftSourceLines && getFileName(opts.shiftSourceLines.sourcePath); + const shiftSourceName = opts.shiftSourceLines && opts.shiftSourceLines.sourcePath; const getLine = (path: string, lineStr: string) => { const line = Number(lineStr); - if (shiftSourceName && getFileName(path) == shiftSourceName) { + if (shiftSourceName && (path == shiftSourceName)) { return line - opts.shiftSourceLines!.skipLines; } else { return line;