-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #666 from ActiveState/enable-symlinks-172342127
Enable linking on other operating systems
- Loading branch information
Showing
8 changed files
with
117 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
param ( [string]$SourceExe, [string]$DestinationPath ) | ||
|
||
$WshShell = New-Object -comObject WScript.Shell | ||
$Shortcut = $WshShell.CreateShortcut($DestinationPath) | ||
$Shortcut.TargetPath = $SourceExe | ||
$Shortcut.Save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build !windows | ||
|
||
package deploy | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/ActiveState/cli/internal/locale" | ||
"github.com/ActiveState/cli/internal/logging" | ||
) | ||
|
||
func link(src, dst string) error { | ||
logging.Debug("Creating symlink, oldname: %s newname: %s", src, dst) | ||
err := os.Symlink(src, dst) | ||
if err != nil { | ||
return locale.WrapInputError( | ||
err, "err_deploy_symlink", | ||
"Cannot create symlink at {{.V0}}, ensure you have permission to write to {{.V1}}.", dst, filepath.Dir(dst)) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// +build windows | ||
|
||
package deploy | ||
|
||
import ( | ||
"os/exec" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/ActiveState/cli/internal/environment" | ||
"github.com/ActiveState/cli/internal/locale" | ||
"github.com/ActiveState/cli/internal/logging" | ||
) | ||
|
||
func link(src, dst string) error { | ||
if strings.HasSuffix(dst, ".exe") { | ||
dst = strings.Replace(dst, ".exe", ".lnk", 1) | ||
} | ||
logging.Debug("Creating shortcut, oldname: %s newname: %s", src, dst) | ||
|
||
root, err := environment.GetRootPath() | ||
if err != nil { | ||
return locale.WrapError( | ||
err, "err_link_get_root", | ||
"Could not get root path of shortcut script", | ||
) | ||
} | ||
scriptPath := filepath.Join(root, "assets", "scripts", "createShortcut.ps1") | ||
|
||
// Some paths may contain spaces so we must quote | ||
src = strconv.Quote(src) | ||
dst = strconv.Quote(dst) | ||
|
||
cmd := exec.Command("powershell.exe", "-Command", scriptPath, src, dst) | ||
return cmd.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters