yonaskolb / Mint

A package manager that installs and runs executable Swift packages
MIT License
2.28k stars 122 forks source link

Add a command to print absolute path of executable commands #152

Closed ainame closed 4 years ago

ainame commented 4 years ago

Hi. Our project started using Mint and had an issue where our CLI toolings require an absolute/relative path of executables. e.g. danger-ruby-swiftlint requires the path to run linting. https://github.com/ashfurrow/danger-ruby-swiftlint/blob/master/ext/swiftlint/swiftlint.rb#L30-L38 I guess it's not a rare case that checks the executable path to see if a tool is installed.

As far as I'm aware, Mint doesn't support an option or a command to print such paths yet (, does it?). Although I know the default directory to install packages is "/usr/local/lib/mint/" and could work out the executable path by myself eventually. But in order to integrate CLI tools managed by Mint and other CI stuff smoothly, I think providing such ability is the most efficient way to do it.

Let's say I installed SwiftLint v0.38.0 via Mint now and found this path.

/usr/local/lib/mint/packages/github.com_realm_SwiftLint/build/0.38.0/swiftlint

I can then work out the path from MINT_PATH + Mintfile with using something like the following command.

$ grep SwiftLint Mintfile | \ 
  ruby -e 'gets.match(/@(.*)/).tap {|c| puts "$(MINT_PATH)/packages/github.com_realm_SwiftLint/build/#{c[1]}/swiftlint" }'

The problem with this is that

So it would be great if Mint has the ability to print the absolute path of the executable by default. My suggestion for the comannd is to integrate such ability with existing command and add an option called something like "--print-executable-path" or add a subcommand called "which" that follows which or gem which command.

mint list PACKAGE_NAME EXECUTABLE_NAME --print-executable-path
or
mint which PACKAGE_NAME EXECUTABLE_NAME

WDYT?

ainame commented 4 years ago

This turned out that I could avoid that issue by having a wrapper shell script for SwiftLint in our project.

scripts/swiftlint.sh

#!/usr/bin/env bash

/usr/bin/env mint run swiftlint "$@"

But not sure if my original suggestion makes sense to others. So will leave this for a while.

ainame commented 4 years ago

This seems to be duplicated with https://github.com/yonaskolb/Mint/pull/73