Skip to content

Commit bac8015

Browse files
y-yagiColinDKelley
authored andcommitted
Use the defined type to the default value of directory
Currently, you will get Thor's deprecated message when starting the `Listen::CLI`. ``` Deprecation warning: Expected array default value for '--directory'; got "." (string). This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION. ``` This is due to the incorrect default value(`directory` is defined as an `array`, but the default value is a `string`). This fixed to use the correct default value and correctly pass to the `directory` to `Listen.to`.
1 parent ec5c88a commit bac8015

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/listen/cli.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class CLI < Thor
1818

1919
class_option :directory,
2020
type: :array,
21-
default: '.',
21+
default: ['.'],
2222
aliases: '-d',
23-
banner: 'The directory to listen to'
23+
banner: 'One or more directories to listen to'
2424

2525
class_option :relative,
2626
type: :boolean,
@@ -55,7 +55,7 @@ def start
5555
end
5656
end
5757

58-
listener = Listen.to(directory, relative: relative, &callback)
58+
listener = Listen.to(*directory, relative: relative, &callback)
5959

6060
listener.start
6161

spec/lib/listen/cli_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
let(:options) { %w[] }
1616
it 'is set to local directory' do
1717
expect(Listen::Forwarder).to receive(:new) do |options|
18-
expect(options[:directory]).to eq('.')
18+
expect(options[:directory]).to eq(['.'])
1919
forwarder
2020
end
2121
described_class.start(options)
@@ -108,7 +108,7 @@
108108
it 'passes relative option to Listen' do
109109
value = double('value')
110110
expect(Listen).to receive(:to).
111-
with(nil, hash_including(relative: value)).
111+
with(hash_including(relative: value)).
112112
and_return(listener)
113113

114114
described_class.new(relative: value).start

0 commit comments

Comments
 (0)