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

Add spherun options to override game path/script path #303

Open
postcasio opened this issue Sep 17, 2019 · 1 comment
Open

Add spherun options to override game path/script path #303

postcasio opened this issue Sep 17, 2019 · 1 comment

Comments

@postcasio
Copy link
Contributor

Use case:

I want to use Spherun to run a script that could exist outside the game directory, while maintaining the ability to load scripts from inside the game directory as if Spherun had been started with the game's manifest.

This means being able to override the game path and start script path, so that any scripts loaded from the game have the correct path resolution for $/ and @/ paths.

e.g.

spherun --gamepath /my/game --startscriptpath /my/game/src /my/testframework/testharness.js

In this example, testharness.js would now be sandboxed to the game directory, even though it doesn't reside there.

@fatcerberus
Copy link
Member

fatcerberus commented Oct 5, 2019

Just posting this for the record.

There's a--not insurmountable!--design limitation to do with this, in that the internal path canonicalizer currently assumes any filename beginning with $/ (the location of the startup script) is always reachable from @/ (the location of the game manifest) and canonicalizes it as such. In this way a game gets guaranteed that FS.fullPath always returns the same path string for the same file, allowing the path to be used as a lookup key for, e.g. caching, map engines (think persist.js-like solutions), etc.

Note that this differs from Cell, which treats $/ and @/ as distinct roots. The potential for aliasing in this case was accepted as a necessary tradeoff in the name of enabling out-of-source builds without compromising the integrity of the SphereFS sandbox.

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

No branches or pull requests

2 participants