Merge pull request #7286 from vladimyr/cask-mdimport

Add `mdimporter` stanza to homebrew cask DSL
This commit is contained in:
Mike McQuaid 2020-04-06 19:24:23 +01:00 committed by GitHub
commit fca9b4aeb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 0 deletions

View File

@ -18,6 +18,7 @@ require "cask/artifact/postflight_block"
require "cask/artifact/preflight_block"
require "cask/artifact/prefpane"
require "cask/artifact/qlplugin"
require "cask/artifact/mdimporter"
require "cask/artifact/screen_saver"
require "cask/artifact/service"
require "cask/artifact/stage_only"

View File

@ -62,6 +62,7 @@ module Cask
Colorpicker,
Prefpane,
Qlplugin,
Mdimporter,
Dictionary,
Font,
Service,

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
require "cask/artifact/moved"
module Cask
module Artifact
class Mdimporter < Moved
def self.english_name
"Spotlight metadata importer"
end
def install_phase(**options)
super(**options)
reload_spotlight(**options)
end
private
def reload_spotlight(command: nil, **_)
command.run!("/usr/bin/mdimport", args: ["-r", target])
end
end
end
end

View File

@ -53,6 +53,7 @@ module Cask
option "--colorpickerdir=PATH", ->(value) { Config.global.colorpickerdir = value }
option "--prefpanedir=PATH", ->(value) { Config.global.prefpanedir = value }
option "--qlplugindir=PATH", ->(value) { Config.global.qlplugindir = value }
option "--mdimporterdir=PATH", ->(value) { Config.global.mdimporterdir = value }
option "--dictionarydir=PATH", ->(value) { Config.global.dictionarydir = value }
option "--fontdir=PATH", ->(value) { Config.global.fontdir = value }
option "--servicedir=PATH", ->(value) { Config.global.servicedir = value }

View File

@ -11,6 +11,7 @@ module Cask
appdir: "/Applications",
prefpanedir: "~/Library/PreferencePanes",
qlplugindir: "~/Library/QuickLook",
mdimporterdir: "~/Library/Spotlight",
dictionarydir: "~/Library/Dictionaries",
fontdir: "~/Library/Fonts",
colorpickerdir: "~/Library/ColorPickers",

View File

@ -39,6 +39,7 @@ module Cask
Artifact::Pkg,
Artifact::Prefpane,
Artifact::Qlplugin,
Artifact::Mdimporter,
Artifact::ScreenSaver,
Artifact::Service,
Artifact::StageOnly,

View File

@ -27,6 +27,7 @@ module RuboCop
:internet_plugin,
:prefpane,
:qlplugin,
:mdimporter,
:screen_saver,
:service,
:audio_unit_plugin,

View File

@ -43,6 +43,20 @@ describe Cask::Cmd, :cask do
expect(Cask::Config.global.qlplugindir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the mdimporterdir" do
described_class.new.process_options("help", "--mdimporterdir=/some/path/foo")
expect(Cask::Config.global.mdimporterdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the mdimporterdir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--mdimporterdir=/some/path/bar"
described_class.new.process_options("help")
expect(Cask::Config.global.mdimporterdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the colorpickerdir" do
described_class.new.process_options("help", "--colorpickerdir=/some/path/foo")

View File

@ -14,6 +14,7 @@ module Cask
appdir: Pathname(TEST_TMPDIR)/"cask-appdir",
prefpanedir: Pathname(TEST_TMPDIR)/"cask-prefpanedir",
qlplugindir: Pathname(TEST_TMPDIR)/"cask-qlplugindir",
mdimporterdir: Pathname(TEST_TMPDIR)/"cask-mdimporter",
dictionarydir: Pathname(TEST_TMPDIR)/"cask-dictionarydir",
fontdir: Pathname(TEST_TMPDIR)/"cask-fontdir",
colorpickerdir: Pathname(TEST_TMPDIR)/"cask-colorpickerdir",