Skip to content

Commit

Permalink
fix asset paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ksjogo committed Jan 9, 2022
1 parent 6d04362 commit 5302d9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion parse_node/parse_source_file.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from "path"

import ts, { SyntaxKind } from "typescript"

import { ErrorName } from "../project"
Expand Down Expand Up @@ -123,7 +125,7 @@ export const parseSourceFile = (
}

parsedClassDeclarations.push({
fileName: props.sourceFileAsset.gdPath,
fileName: props.sourceFileAsset.pathForClassname(className),
parsedClass: parsedStatement,
classDecl,
})
Expand Down
12 changes: 10 additions & 2 deletions project/assets/asset_source_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/ " */
Expand All @@ -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 {
Expand Down Expand Up @@ -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 = []

Expand Down

0 comments on commit 5302d9b

Please sign in to comment.