I have a simple dart project that has one executable in bin folder (test.dart). I have activated it with dart global activate and now I can run it directly with just typing the name of that executable file.
Inside that dart file I would like to know the path of that script. Basically for now I'm just printing something like this:
print('1: ' + Platform.script.toString()); print('2: ' + Platform.script.path); print('3: ' + Platform.executable); print('4: ' + Platform.packageRoot); print('5: ' + Platform.resolvedExecutable);
When I run it directly:
or with pub:
pub global run test
or even with package name:
pub global run test:test
I always get the same result:
1: http://localhost:53783/test.dart 2: /test.dart 3: E:\apps\dart-sdk\bin\dart 4: 5: E:\apps\dart-sdk\bin\dart.exe
The issue here is that I can't get the absolute path for test.dart file.
When I run it like this:
I get what I need:
1: file:///E:/projects/dart/test/bin/test.dart 2: /E:/projects/dart/test/bin/test.dart 3: dart 4: 5: E:\apps\dart-sdk\bin\dart.exe
Is there a way how to get absolute path for a script that is currently running, regardless of a way how it was executed?
You received this message because you are subscribed to the Google Groups "Dart Server-side and Cloud Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud+un...@dartlang.org.
Visit this group at https://groups.google.com/a/dartlang.org/group/cloud/.