Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent path resolution in imports and sdk commands #77

Open
x87 opened this issue Nov 24, 2022 · 2 comments
Open

inconsistent path resolution in imports and sdk commands #77

x87 opened this issue Nov 24, 2022 · 2 comments

Comments

@x87
Copy link
Contributor

x87 commented Nov 24, 2022

complex scripts could be organized in folders and subfolders. For example

- \CLEO
-- \MegaMod
--- \extra
---- addon.js
---- model.mjs
---- lib.dll
--- index.js

import statements allows usage of ./ as the current file's directory. It resolves to CLEO/MegaMod/extra/ in addon.js and to CLEO/MegaMod/ in index.js.

SDK commands allows ./ too. But it always resolves to the index.js directory, regardless of the file location.

addon.js

import './model.mjs'; // works

DynamicLibrary.Load('./lib.dll'); // does not work, `CLEO/MegaMod/lib.dll` does not exist

DynamicLibrary.Load('./extra/lib.dll'); // works
@x87
Copy link
Contributor Author

x87 commented Nov 25, 2022

SDK command path allows CLEO\ prefix to be resolved as a path to CLEO directory. In imports there is no such logic, it resolves relative to current working directory (game root):

addon.js

import 'CLEO/MegaMod/extra/model.mjs'; // does not work if CLEO folder is not in root

DynamicLibrary.Load('CLEO/MegaMod/extra/lib.dll'); // works

@x87
Copy link
Contributor Author

x87 commented Nov 29, 2022

Added a note in SDK docs https://re.cleo.li/docs/en/using-sdk.html#path-resolution-convention
The workaround for SDK commands is to use __dirname for file path

DynamicLibrary.Load(__dirname + "\mylib.dll");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant