Skip to content

Commit

Permalink
Add $dirname identifier in plugin with meta.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Jan 6, 2024
1 parent 7cdca52 commit 3225099
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xray16",
"version": "1.0.17",
"version": "1.1.0",
"author": "Neloreck",
"repository": "https://github.com/stalker-xrts/xray-16-types",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SyntaxKind } from "typescript";
import { createStringLiteral, Plugin } from "typescript-to-lua";

const FILENAME_IDENTIFIER: string = "$filename";
const DIRNAME_IDENTIFIER: string = "$dirname";

/**
* Plugin that injects FILE_NAME in compile-time.
Expand All @@ -15,6 +16,10 @@ const plugin: Plugin = {
return createStringLiteral(path.parse(context.sourceFile.fileName).name);
}

if (node.text === DIRNAME_IDENTIFIER) {
return createStringLiteral(path.basename(path.dirname(context.sourceFile.fileName)));
}

return context.superTransformExpression(node);
},
},
Expand Down

0 comments on commit 3225099

Please sign in to comment.