popomore / projj

Manage repository easily.
MIT License
266 stars 40 forks source link

fix: fix error when iterm is not installed #35

Closed DiamondYuan closed 5 years ago

codecov[bot] commented 5 years ago

Codecov Report

Merging #35 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #35   +/-   ##
=======================================
  Coverage   99.61%   99.61%           
=======================================
  Files          11       11           
  Lines         259      259           
=======================================
  Hits          258      258           
  Misses          1        1
Impacted Files Coverage Δ
lib/command/find.js 100% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 444dee9...3769deb. Read the comment docs.

DiamondYuan commented 5 years ago
function   generateAppleScript(dir) {
  const terminalCommand = `tell application "Terminal"
  do script "cd ${dir}"  in front window 
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

  const iTermCommand = `tell application "iTerm"
  tell current session of current window
    write text "cd ${dir}"
  end tell
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

  const currentApp = `tell application "System Events"
  set activeApp to name of first application process whose frontmost is true
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');
  return `[ \`osascript ${currentApp}\` = "Terminal" ] && osascript ${terminalCommand} >/dev/null || osascript ${iTermCommand}`;
}
console.log(generateAppleScript("~"))

把 iTerm 改成 xxx 后 在 Terminal 下 没有报错。那应该是没问题了。

function   generateAppleScript(dir) {
  const terminalCommand = `tell application "Terminal"
  do script "cd ${dir}"  in front window 
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

  const iTermCommand = `tell application "xxxx"
  tell current session of current window
    write text "cd ${dir}"
  end tell
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

  const currentApp = `tell application "System Events"
  set activeApp to name of first application process whose frontmost is true
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');
  return `[ \`osascript ${currentApp}\` = "Terminal" ] && osascript ${terminalCommand} >/dev/null || osascript ${iTermCommand}`;
}
console.log(generateAppleScript("~"))
popomore commented 5 years ago