From 5302d9b0b97fa0dbebb289710463f0354a6f811c Mon Sep 17 00:00:00 2001 From: Johannes Goslar Date: Sun, 9 Jan 2022 15:51:06 +0100 Subject: [PATCH] fix asset paths --- parse_node/parse_source_file.ts | 4 +++- project/assets/asset_source_file.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/parse_node/parse_source_file.ts b/parse_node/parse_source_file.ts index e76ada0..1e5482e 100644 --- a/parse_node/parse_source_file.ts +++ b/parse_node/parse_source_file.ts @@ -1,3 +1,5 @@ +import path from "path" + import ts, { SyntaxKind } from "typescript" import { ErrorName } from "../project" @@ -123,7 +125,7 @@ export const parseSourceFile = ( } parsedClassDeclarations.push({ - fileName: props.sourceFileAsset.gdPath, + fileName: props.sourceFileAsset.pathForClassname(className), parsedClass: parsedStatement, classDecl, }) diff --git a/project/assets/asset_source_file.ts b/project/assets/asset_source_file.ts index a736abe..ea7835f 100644 --- a/project/assets/asset_source_file.ts +++ b/project/assets/asset_source_file.ts @@ -22,7 +22,11 @@ export class AssetSourceFile extends AssetBase { readonly gdClassName: string - /** Like "/Users/johnfn/GodotProject/compiled/main.gd" */ + /** Like "/Users/johnfn/GodotProject/compiled/main.gd" + * Beware that this only is correct if the className corresponds to the file name + * Should be refactored, maybe add the contained classnames to the Asset + * @deprecated + */ readonly gdPath: string /** Like "/Users/johnfn/GodotProject/compiled/ " */ @@ -48,6 +52,10 @@ export class AssetSourceFile extends AssetBase { ) } + pathForClassname(className: string) { + return path.join(this.gdContainingDirectory, `${className}.gd`) + } + reload() {} private getAst(): TsGdError | ts.SourceFile { @@ -342,7 +350,7 @@ Second path: ${chalk.yellow(sf.fsPath)}`, }) // TODO: Only do this once per program run max! - await fs.mkdir(path.dirname(this.gdPath), { recursive: true }) + await fs.mkdir(this.gdContainingDirectory, { recursive: true }) this.writtenFiles = []