lib / win32_shortcut.json commit git gui: fix staging a second line to a 1-line file (6d02c1e)
   1// git-gui Windows shortcut support
   2// Copyright (C) 2007 Shawn Pearce
   3
   4var WshShell = WScript.CreateObject("WScript.Shell");
   5var argv = WScript.Arguments;
   6var argi = 0;
   7var lnk_path = argv.item(argi++);
   8var ico_path = argi < argv.length ? argv.item(argi++) : undefined;
   9var dir_path = argi < argv.length ? argv.item(argi++) : undefined;
  10var lnk_exec = argi < argv.length ? argv.item(argi++) : undefined;
  11var lnk_args = '';
  12while (argi < argv.length) {
  13        var s = argv.item(argi++);
  14        if (lnk_args != '')
  15                lnk_args += ' ';
  16        if (s.indexOf(' ') >= 0) {
  17                lnk_args += '"';
  18                lnk_args += s;
  19                lnk_args += '"';
  20        } else {
  21                lnk_args += s;
  22        }
  23}
  24
  25var lnk = WshShell.CreateShortcut(lnk_path);
  26if (argv.length == 1) {
  27        WScript.echo(lnk.TargetPath);
  28} else {
  29        lnk.TargetPath = lnk_exec;
  30        lnk.Arguments = lnk_args;
  31        lnk.IconLocation = ico_path + ", 0";
  32        lnk.WorkingDirectory = dir_path;
  33        lnk.Save();
  34}