From fae2052f2efd250ba8e5a916a1df65c0f1aa751a Mon Sep 17 00:00:00 2001 From: John Sterling Date: Mon, 18 Nov 2019 22:12:26 +0100 Subject: [PATCH] Relax some rules, fix focus bug --- Finicky/Finicky.xcodeproj/project.pbxproj | 4 ++-- Finicky/Finicky/AppDelegate.swift | 19 +++++++++---------- Finicky/Finicky/finickyConfigAPI.js | 2 +- config-api/src/cli.ts | 8 -------- config-api/src/types.ts | 2 +- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Finicky/Finicky.xcodeproj/project.pbxproj b/Finicky/Finicky.xcodeproj/project.pbxproj index 601f14e..f53defc 100644 --- a/Finicky/Finicky.xcodeproj/project.pbxproj +++ b/Finicky/Finicky.xcodeproj/project.pbxproj @@ -465,7 +465,7 @@ INFOPLIST_FILE = Finicky/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = v2.2.2; + MARKETING_VERSION = v2.2.3; PRODUCT_BUNDLE_IDENTIFIER = net.kassett.finicky; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Finicky/Finicky-Bridging-Header.h"; @@ -482,7 +482,7 @@ INFOPLIST_FILE = Finicky/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = v2.2.2; + MARKETING_VERSION = v2.2.3; PRODUCT_BUNDLE_IDENTIFIER = net.kassett.finicky; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Finicky/Finicky-Bridging-Header.h"; diff --git a/Finicky/Finicky/AppDelegate.swift b/Finicky/Finicky/AppDelegate.swift index 35b19ba..7a7f5df 100644 --- a/Finicky/Finicky/AppDelegate.swift +++ b/Finicky/Finicky/AppDelegate.swift @@ -158,15 +158,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele func getPidPath(pid: Int32) -> String? { let pathBuffer = UnsafeMutablePointer.allocate(capacity: Int(MAXPATHLEN)) - defer { - pathBuffer.deallocate() - } - let pathLength = proc_pidpath(pid, pathBuffer, UInt32(MAXPATHLEN)) + defer { + pathBuffer.deallocate() + } + let pathLength = proc_pidpath(pid, pathBuffer, UInt32(MAXPATHLEN)) - if pathLength > 0 { - let path = String(cString: pathBuffer) + if pathLength > 0 { + let path = String(cString: pathBuffer) return path - } + } return nil } @@ -229,9 +229,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele showTestConfigWindow(nil) } - func openUrlWithBrowser(_ url: URL, bundleIdentifier: String, openInBackground: Bool?) { - // Launch in background by default if finicky isn't active to avoid something that causes some bug to happen... - let openInBackground = openInBackground ?? !isActive + func openUrlWithBrowser(_ url: URL, bundleIdentifier: String, openInBackground: Bool?) { + let openInBackground = openInBackground ?? false print("Opening " + bundleIdentifier + " at: " + url.absoluteString) let command = getBrowserCommand(bundleIdentifier, url: url, openInBackground: openInBackground) shell(command) diff --git a/Finicky/Finicky/finickyConfigAPI.js b/Finicky/Finicky/finickyConfigAPI.js index 0867d22..1732aad 100644 --- a/Finicky/Finicky/finickyConfigAPI.js +++ b/Finicky/Finicky/finickyConfigAPI.js @@ -229,7 +229,7 @@ var finickyConfigApi = (function (exports) { url: validate.oneOf([ validate.string, validate.shape({ - protocol: validate.oneOf(["http", "https", "file"]).isRequired, + protocol: validate.string.isRequired, username: validate.string, password: validate.string, host: validate.string.isRequired, diff --git a/config-api/src/cli.ts b/config-api/src/cli.ts index b81264a..0f37658 100755 --- a/config-api/src/cli.ts +++ b/config-api/src/cli.ts @@ -35,14 +35,6 @@ const url = args[0] || "https://example.com/test"; const protocol = urlParse(url).protocol.replace(":", ""); -if (protocol !== "http" && protocol !== "https" && protocol !== "file") { - errorMessage( - chalk`Finicky only processes {underline file, http and https} urls. Supplied url has protocol:`, - protocol - ); - process.exit(1); -} - console.log(chalk`Opening configuration file {dim ${configPath}}`); let config; diff --git a/config-api/src/types.ts b/config-api/src/types.ts index 5a01d8a..3a27e52 100644 --- a/config-api/src/types.ts +++ b/config-api/src/types.ts @@ -157,7 +157,7 @@ export const urlSchema = { url: validate.oneOf([ validate.string, validate.shape({ - protocol: validate.oneOf(["http", "https", "file"]).isRequired, + protocol: validate.string.isRequired, username: validate.string, password: validate.string, host: validate.string.isRequired,