Closed JohnSundell closed 7 years ago
@darthpelo @pixyzehn @kareman @alexaubry Would love your thoughts on this π
This looks great, I have been wanting something like this for a long time.
@kareman Happy to hear that π It's gonna make sharing scripts so much smoother, no need for extra files like a Marathonfile
.
@JohnSundell Looks awesome!! It might be better to update README about adding support for inline dependency resolutionπ
@pixyzehn awesome suggestion - done! β
I love the idea! π
Maybe you could improve the performance by using String range/index search methods like range(of:)
/ rangeOfCharacter(from:)
/ substring(with:)
instead of separating components? (learned this when building HTMLString)
@alexaubry Would that be more performant though, since I'd need to keep searching the entire string until all imports have been parsed? Separating components should be O(N)
, even if consumes a bit more memory (but shouldn't be a problem here since we're dealing with relatively small data sets on powerful hardware π)
@JohnSundell not that much, we're talking a few milliseconds. If that's not a concern it's probably better to keep it simple π
@alexaubry Agreed π π
Tests seem to be quite flaky due to parallelization, gonna take care of that in a separate PR before merging this one π
Dropping the parallelization on Linux for now, gonna investigate it further at a later point π
This change adds support for specifying dependencies inline, instead of having to use a Marathonfile. A comment can now simply be added next to an
import
statement, specifying the URL that the dependency can be found at, and Marathon will automatically add that dependency, just like when a Marathonfile is used.The implementation is a bit naive, as it simply splits the script file based on new lines and iterates through them (although an optimization has been made to stop as soon as a non-import alphanumeric character is found). A more optimized solution would probably be to stream the file and keep reading bytes until all imports have been parsed.
Resolves https://github.com/JohnSundell/Marathon/issues/34