Skip to content

Commit

Permalink
Refuse to run if setup.lua can't be opened/parsed. Relates to issue #17
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Oct 30, 2014
1 parent a293451 commit 0b027f8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Hammerspoon/MJLua.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ void MJLuaSetup(void) {
luaL_newlib(L, corelib);
lua_setglobal(L, "hs");

luaL_loadfile(L, [[[NSBundle mainBundle] pathForResource:@"setup" ofType:@"lua"] fileSystemRepresentation]);
int loadresult = luaL_loadfile(L, [[[NSBundle mainBundle] pathForResource:@"setup" ofType:@"lua"] fileSystemRepresentation]);
if (loadresult != 0) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:@"Hammerspoon installation is corrupted"];
[alert setInformativeText:@"Please re-install Hammerspoon"];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
[[NSApplication sharedApplication] terminate: nil];
}

lua_pushstring(L, [[[NSBundle mainBundle] pathForResource:@"extensions" ofType:nil] fileSystemRepresentation]);
lua_pushstring(L, [MJConfigFile UTF8String]);
Expand Down

0 comments on commit 0b027f8

Please sign in to comment.