aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPBundleEditorController.m3
-rw-r--r--Source/SPBundleHTMLOutputController.m64
-rw-r--r--Source/SPStringAdditions.m2
3 files changed, 64 insertions, 5 deletions
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 99da4bc4..272221d4 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -1086,7 +1086,8 @@
}
if(newKeyCombo.flags & NSCommandKeyMask)
[keyEq appendString:@"@"];
- [keyEq appendString:theChar];
+ if(theChar)
+ [keyEq appendString:theChar];
}
[[self _currentSelectedObject] setObject:keyEq forKey:SPBundleFileKeyEquivalentKey];
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index e675e9f5..c57c79f4 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -22,7 +22,6 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-
#import "SPBundleHTMLOutputController.h"
#import "SPAlertSheets.h"
@@ -359,9 +358,68 @@
[webScriptObject setValue:self forKey:@"system"];
}
-- (NSString *)run:(NSString*)command
+- (NSString *)run:(id)call
{
- return [NSString stringWithFormat:@"Hallo-%@", [command description]];
+
+ NSError *err = nil;
+ NSString *command = nil;
+ NSString *uuid = nil;
+
+ if([call isKindOfClass:[NSString class]])
+ command = [NSString stringWithString:call];
+ else if([[[call class] description] isEqualToString:@"WebScriptObject"]){
+ command = [call webScriptValueAtIndex:0];
+ uuid = [call webScriptValueAtIndex:1];
+ }
+ else {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while executing JavaScript BASH command", @"error while executing javascript bash command")
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:NSLocalizedString(@"Passed parameter couldn't be interpreted. Only string or array (with 2 elements) are allowed.", @"Passed parameter couldn't be interpreted. Only string or array (with 2 elements) are allowed.")];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return @"";
+ }
+
+ if(!command) return @"No JavaScript command found.";
+
+ NSString *output = nil;
+ if(uuid == nil)
+ output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];
+ else
+ output = [command runBashCommandWithEnvironment:nil
+ atCurrentDirectoryPath:nil
+ callerInstance:[NSApp delegate]
+ contextInfo:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"JavaScript", @"name",
+ NSLocalizedString(@"General", @"general menu item label"), @"scope",
+ uuid, SPBundleFileInternalexecutionUUID,
+ nil]
+ error:&err];
+
+
+ if(err != nil) {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while executing JavaScript BASH command", @"error while executing javascript bash command")
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[err localizedDescription]];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return @"";
+ }
+
+ if(output)
+ return output;
+ else {
+ NSLog(@"No valid output for JavaScript command found.");
+ NSBeep();
+ return @"";
+ }
+
}
#pragma mark -
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index 4b06a028..a3098750 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -462,7 +462,7 @@
NSMutableArray *scriptHeaderArguments = [NSMutableArray array];
NSString *scriptPath = @"";
- NSString *uuid = (contextInfo && [contextInfo objectForKey:SPBundleFileInternalexecutionUUID]) ? [contextInfo objectForKey:@"exeUUID"] : [NSString stringWithNewUUID];
+ NSString *uuid = (contextInfo && [contextInfo objectForKey:SPBundleFileInternalexecutionUUID]) ? [contextInfo objectForKey:SPBundleFileInternalexecutionUUID] : [NSString stringWithNewUUID];
NSString *stdoutFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskOutputFilePath, uuid];
NSString *scriptFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskScriptCommandFilePath, uuid];