Skip to content
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

feat: update runtime.selectFile() to also return the file name #81

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Jan 7, 2025

Updates runtime.selectFile() to return an object that contains the path and name of the selected file, as opposed to just the path. Informed by the needs of #55

@achou11 achou11 requested a review from cimigree January 7, 2025 20:25
Comment on lines +49 to +61
function validateSelectedFileResult(value) {
if (!('path' in value && 'name' in value)) {
throw new Error('Value has invalid shape')
}

if (typeof value.path !== 'string') {
throw new Error('Value has invalid path field')
}

if (typeof value.name !== 'string') {
throw new Error('Value has invalid name field')
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally would use valibot for this but I don't have bundling set up for the preload just yet so I think it would require some additional tooling work.

@achou11 achou11 force-pushed the ac/runtime-select-file-expose-name branch from d496f0d to d363615 Compare January 7, 2025 20:26
@achou11 achou11 mentioned this pull request Jan 7, 2025
@achou11 achou11 force-pushed the ac/runtime-select-file-expose-name branch from d363615 to 1813e4e Compare January 7, 2025 20:32
Copy link
Contributor

@cimigree cimigree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@achou11 achou11 merged commit 80b5fb5 into main Jan 7, 2025
4 checks passed
@achou11 achou11 deleted the ac/runtime-select-file-expose-name branch January 7, 2025 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants