Created
June 2, 2013 16:59
-
-
Save tuxtina/5694143 to your computer and use it in GitHub Desktop.
Quick & dirty PHP syntax check on save for use with TextWrangler. Put into ~/Library/ApplicationSupport/TextWrangler/Attachment Scripts/Document.scpt.
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
on documentDidSave(currentDoc) | |
set fileName to the name of the currentDoc as string | |
if ((offset of ".php" in fileName) > 1) then | |
set f to the file of the currentDoc | |
set filePath to the POSIX path of f | |
set lintOutput to do shell script "php -l \"" & filePath & "\"; exit 0" | |
if ((offset of "No syntax errors detected" in lintOutput) ≠ 1) then | |
display dialog lintOutput buttons {"OK"} default button "OK" with title "PHP Syntax Error" | |
end if | |
end if | |
end documentDidSave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment