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: support create a desktop for link #89

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api-type-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @property {string} [hotkey] A global hotkey to associate to opening this shortcut, like 'CTRL+ALT+F'.
* @property {string} [workingDirectory] The working directory for the shortcut when it launches, must be a valid path to a folder.
* @property {string} [VBScriptPath] This is an advanced option specifically and only for projects packaged with `pkg`.
* @property {string} [isLink] This parameter indicates that it is a link or deeplink, It is using either the "http://" or "https://" protocol or a custom deeplink protocol.
* [See documentation](https://github.com/nwutils/create-desktop-shortcuts#windows-settings).
*/

Expand Down
4 changes: 3 additions & 1 deletion src/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ const validation = {
windowsFilePath = helpers.resolveWindowsEnvironmentVariables(windowsFilePath);
windowsFilePath = this.resolvePATH(windowsFilePath);
Comment on lines 398 to 399
Copy link
Member

Choose a reason for hiding this comment

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

  • There needs to be some basic safety checking for this feature (see suggestion below).
  • Also the isLink should be checked as a optional boolean defaulting to false in the validation file.
  • There needs to be unit tests created to ensure the repo stays at 100% test coverage.
  • The documentation in the README needs updated as well to convey this new feature.
Suggested change
windowsFilePath = helpers.resolveWindowsEnvironmentVariables(windowsFilePath);
windowsFilePath = this.resolvePATH(windowsFilePath);
if (options.windows.isLink) {
if (
typeof(windowsFilePath) !== 'string' ||
!windowsFilePath.includes('://')
) {
helpers.throwError(options, 'WINDOWS filePath must be a string of a URL when isLink is true:' + windowsFilePath);
delete options.windows;
}
return options;
}
windowsFilePath = helpers.resolveWindowsEnvironmentVariables(windowsFilePath);
windowsFilePath = this.resolvePATH(windowsFilePath);

}

if (options.windows.isLink) {
return options;
}
if (
!windowsFilePath ||
typeof(windowsFilePath) !== 'string' ||
Expand Down
Loading