-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix archives that are wrapped in a directory #11
base: main
Are you sure you want to change the base?
Conversation
4e09472
to
53e31cc
Compare
Fixes the case if kit binary is wrapped in a directory. Also fixes the markdownlint issues.
const extractedDir = path.dirname(extractedPath) | ||
const files = fs.readdirSync(extractedDir, { | ||
withFileTypes: true, | ||
recursive: true | ||
}) | ||
const kitExecutable = files.filter( | ||
file => file.isFile() && file.name === getExecutableBinaryName() | ||
) | ||
if (kitExecutable.length === 0) { | ||
throw new Error( | ||
`Failed to find executable binary in extracted archive: ${archive}` | ||
) | ||
} | ||
// In some cases, the extracted binary is in a subdirectory of the extracted archive | ||
// In this case, move the binary to the root of the extracted archive | ||
ghCore.debug( | ||
`Checking if extracted binary is in a subdirectory for ${kitExecutable[0].name} on path ${kitExecutable[0].path}` | ||
) | ||
if (kitExecutable[0].path === extractedPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to still not work:
- In the files.filter() call, won't checking
file => isFile()
prevent getting any dirs (assuming you want to match the wrapping directory) - Checking
file.name === getExecutableBinaryName()
also might not work; in the case of wrapped dirs on macos, the dir name iskit-darwin-amd64
or similar (i.e. notkit
). On windows, the binary name iskit.exe
which will never match a dir.
Testing locally, I'm seeing failures (in both case, ::error::Failed to find executable binary in extracted archive: <longname>
):
- With latest, the jozu-bin dir contains
/var/[...]/jozu-bin ├── LICENSE ├── README.md └── kit
- With v0.1.3, the jozu-bin dir contains
/var/[...]/jozu-bin └── kitops-darwin-arm64 ├── LICENSE ├── README.md └── kit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking locally, I don't know if
const extractedDir = path.dirname(extractedPath)
is correct -- on my system, extractedPath
is /var/[...]/T/jozu-bin
, so taking the dirname gives /var/[...]/T/
, which will not contain the extracted files.
Fixes the case if kit binary is wrapped in a directory.