Comments (4)
This is a... workaround?... if you will, but I'll trigger notifications via osascript a lot to keep my sanity on if I've coded things correctly in hooks, such as correct criteria and/or error capturing.
To capture errors, push the stderr to the stdout, then use good o'l /dev/null:
err="$(ehco 'blah' 2>&1 1>/dev/null)"
if [ -n "$err" ]; then
osascript -e "display notification \"$err\" with title \"Hook Script Error\""
fi
The above I've typo'd echo
and it'll get a notification alert that states the line number of error and command that caused it.
And if you want validation on both err and success you could else it via:
err="$(echo 'blah' 2>&1 1>/dev/null)"
if [ -n "$err" ]; then
osascript -e "display notification \"$err\" with title \"Hook Script Error\""
else
osascript -e "display notification \"SUCCESS! My code ain't broke!!\" with title \"Woot!\""
fi
from codekit.
Implemented for Beta 2. Here's how it works:
For Bash Hooks:
You will see messages in the Log when any of these circumstances are met:
- Your Hook throws an exception. Previously, CodeKit would just crash. In the future, CodeKit may still crash if your script is just so janked that the app can't recover. But for simple exceptions, such as a launch path not being accessible, you should now receive a message in the log. Note: if anyone can come up with a script that throws an exception to test this, that would be great.
- Your Hook returns a non-zero exit value. If your Hook does this, it is expected that you've written something to StdErr. If you have, you'll see it in the Log. If you have not, then you'll see a message in the log telling you that Hook X returned a non-zero value but didn't log anything to StdErr.
- Your Hook returns a zero exit code and writes anything to StdOut You'll see whatever is written to StdOut in CodeKit's log.
Note:
If it's amateur hour and you return 0
but write output to StdErr (here's looking at you, TypeScript!), that won't be logged. Likewise, if you return non-zero but write to StdOut, that won't be logged either. Program correctly. The error level of the logged message will be regular
(green) for StdOut messages and error
(red) for StdErr messages.
For AppleScript Hooks:
There is a new API in the scripting dictionary for Beta 2. You can use this to log any message with any error level (regular, warning, or "problem" --- because error
is a reserved word in AppleScript).
from codekit.
I should also mention an important implementation detail. Suppose you highlight 5 files in CodeKit and click Process All
. Each of these files meets the criteria to trigger a given Hook.
The way CodeKit works, all five of these files will be processed using the settings you've specified in the app (syntax check, transpile, minify, etc.) BEFORE any Hooks are run. That is, the Hook is run at the end of the group of files being processed, not after each individual file is processed.
When the build process is complete, this will still apply. During a build, files will be "grouped" based on their dependencies. If File X
imports the output of File A
, then A will compile in one "flight" or "group" and then when that group is finished, X will compile in a second group. Hooks will be run at the end of each "flight" or group.
This is basically for performance reasons.
from codekit.
Nice! I'll try to give this a go on next release! Great addition.
from codekit.
Related Issues (20)
- Sometimes losing ES6 Bundle format settings HOT 2
- How to import CSS into JS HOT 1
- Pug Output Style HOT 1
- PurgeCSS wrongly removes all Tailwind-style colon classes HOT 3
- Drag 'n drop crashes app HOT 7
- Not working with DDEV
- Hooks fail to run npm scripts HOT 1
- Browser refresh makes page go to top of site, then scrolls down HOT 2
- CodeKit slow in responsive mode in Chrome ONLY HOT 3
- Using index stylesheets in scss with the new @use and @forward rules is broken HOT 3
- Sonoma GUI Issues HOT 2
- Refresh delay affects stylesheet injection too? HOT 3
- Disable refresh delay for stylesheets when using inject and override remote CSS HOT 4
- [CodeKit 3.26] "Send feedback" switches to the browser but no link is opened HOT 2
- [CodeKit 3.26] Upgrading a project failes HOT 4
- Don't drop Libsass HOT 1
- CodeKit flikker and resets itself HOT 2
- I renewed my license, and now I'm getting build warnings. HOT 5
- @Compile isn't working for js imports HOT 2
- When the log populates with information, it does not scroll down entirely
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codekit.