Reputation: 2585
When I see my $HOME/.pub-cache/bin executables the normal template is:
#!/usr/bin/env sh
# This file was created by pub v1.24.2.
# Package: <package>
# Version: <package_version>
# Executable: <package>
# Script: <package>
pub global run <package>:<package> "$@"
However things go different with stagehand
#!/usr/bin/env sh
# This file was created by pub v1.24.2.
# Package: stagehand
# Version: 1.1.6
# Executable: stagehand
# Script: stagehand
dart "$HOME/.pub-cache/global_packages/stagehand/bin/stagehand.dart.snapshot" "$@"
# The VM exits with code 253 if the snapshot version is out-of-date.
# If it is, we need to delete it and run "pub global" manually.
exit_code=$?
if [ $exit_code != 253 ]; then
exit $exit_code
fi
pub global run stagehand:stagehand "$@"
I would like to know how to achieve this customization without post-install hacks
Upvotes: 0
Views: 380
Reputation: 6171
The difference is that stagehand registers an executable.
This means you can just run stagehand
and it works.
It also means that a snapshot is created for that executable (as you noticed).
See also https://www.dartlang.org/tools/pub/pubspec#executables
Add an executables section to your pubspec and you should be golden!
Edit: also, you won't get this with path-activated packages. The idea: ensure you keep running from your local source.
Upvotes: 1