Malformed Hooks can crash CodeKit, so be sure to double-check your code. Remember that each Hook will be run once for every matching file. So if YOU add the Hook that deletes your Documents folder.I hope you have a backup. CodeKit will run exactly what you tell it to run, every time the criteria you specify are met. ![]() That said, there is no safety net to protect you from yourself. Once you verify that the source code for each Hook is safe, you can manually re-enable them by checking the box pictured. When this happens, you'll see an alert and the app will automatically disable the new/changed Hooks. CodeKit automatically detects when a Hook's source code has changed since you last saw it. Are you about to delete your Documents folder next time you save? Your co-worker commits his changes, you pull, and CodeKit syncs the project. Imagine that you have a shared CodeKit project and an evil co-worker adds this Hook: rm -rf ~/Documents. Additionally, your script must be able to run under the privileges of the current user- sudo is prohibited. That is, your script cannot have prompts that require human input. Note: You can also use CodeKit's Scripting API to log something at any time. If your Hook exits with code 0, CodeKit will log whatever it writes to StdOut. If your Hook exits with a non-zero code, the entry will be marked as an error and CodeKit will log whatever your Hook writes to StdErr. Hook output appears in CodeKit's log entry for the affected file, just like output from CodeKit's built-in processing steps. $CK_PROJECT_ROOT/node_modules/myModule doStuff -optionA (In CodeKit 3.0.5 and above.)įor example, if you've installed custom NPM packages in your project and want to call one of them in a Hook, you might write: You can use the environment variable $CK_PROJECT_ROOT to get the project's root folder. (Unless you have enabled an output file for child.scss, in which case CodeKit would compile both files and run any matching Hook twice.) ![]() For example, if parent.scss imports child.scss and you save child.scss in your editor, CodeKit will compile parent.scss and that's the path you'll find in the environment variables. The paths in these variables may not be those of the file that was actually saved. In this Hook, handlebars is called to compile the changed file at $CK_INPUT_PATH and it's told to write the output to $CK_OUTPUT_PATH. The screenshot above shows these variables in action.
0 Comments
Leave a Reply. |