On Sep 13, 2011, at 16:59, Daniel wrote:
> So I've been working to integrate JSLint more tightly into my coding 
> workflow. Obviously, running it from the web interface is a pain but luckily 
> I got it running on the command line {SNIP}
> 
> The process I have now is that I copy the file path from the BBEdit UI (File 
> Path Copy Path), then I open terminal and type "cat /path/to/ file | jslint"
______________________________________________________________________

Hey Daniel,

Here's a way to do it through the Terminal

----------------------------------------------------------------------
# MAIN
----------------------------------------------------------------------
try
  tell application "BBEdit"
    tell front text document
      if modified = true then
        save its document
      end if
      set bbDocFile to its file
      if bbDocFile ≠ missing value then
        set bbDocPosixPath to POSIX path of bbDocFile
      else
        error "Document Is Unsaved!"
      end if
    end tell
  end tell
  set cmdStr to "cat " & (quoted form of bbDocPosixPath) & " | jslint"
  tell application "Terminal"
    if busy of front window = false then
      do script cmdStr in selected tab of front window
    else
      do script cmdStr
    end if
  end tell
on error eMsg number eNum
  stdErrAS(eMsg, eNum, true, true) of me
end try

----------------------------------------------------------------------
# » stdErrAS() : GENERAL ERROR HANDLER     MODIFIED 2011-09-13 : 05:36
----------------------------------------------------------------------
on stdErrAS(eMsg, eNum, beepFlag, ddFlag)
  set sep to "-----------------------------------"
  set e to sep & return & "Error: " & eMsg & return & sep & return ¬
    & "Error Number: " & eNum & return & sep
  if beepFlag = true then
    beep
  end if
  if ddFlag = true then
    tell me to display dialog e
  else
    return e
  end if
end stdErrAS
----------------------------------------------------------------------

Here's a way to do it using a BBEdit worksheet:

tell application "BBEdit"
  try
    tell front text document
      set f to POSIX path of (get its file)
      set f to quoted form of f
    end tell
    set cmd to "cat " & f & " | jslint"
    set w to make new shell document with properties {contents:cmd}
    set bounds of w's window to {0, 44, 1314, 1196}
    
  on error errMsg number errNum
    set sep to "=============================="
    set e to sep & return & "Error: " & errMsg & return & sep & return ¬
      & "Error Number: " & errNum & return & sep
    beep
    display dialog e
  end try
end tell

** This second script is quick and dirty and has only general error-checking.

--

There are some more possibilities.  Where are you wanting to output?

--
Best Regards,
Chris

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to