-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Jekyll Source Directory #42
Conversation
In some Jekyll setups, the site assets are in a sub-directory. The drafts command, does not process any configuration files or allow to set the site source. Add these options to the draft command and update the FileCreator class to take an optional root that will be prepended to the file.path.
Load in Jekyll configuration when parsing args. Add source method to return Jekyll source directory and update the drafts command to use this new method.
Update the page command to use the correct Jekyll source from config or command line option.
Update post command to respect any custom Jekyll source.
Update Publish command to allow custom Jekyll source. Update MovementArgParser to generate Jekyll config like was done with ArgParser. Update FileMover to automatically use a root directory if given.
Update Unpublish command to allow custom Jekyll source.
Both Publish and Unpublish take in the relative path as the argument, so prepending the root directory won't give you the correct path to the file. Just prepend the root directory to the target path.
Seems logical to me. LGTM. @jekyll/compose? |
@@ -24,4 +25,8 @@ def title | |||
def force? | |||
!!options["force"] | |||
end | |||
|
|||
def source | |||
source = config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable assign necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other methods had an assign, so I thought I would follow that pattern. I can remove this if it isn't doing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I hadn't noticed that. I'm pretty confident those do nothing, would you remove all three?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'll update that tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this and removed all unnecessary variable assignments in that class.
Great work! My only feedback would be that the specs are becoming hard to read, because of the overriding of If you have the time to refactor that to make it clearer, that would be amazing! If not, this is mergable as-is. LGTM |
@courajs I haven't done much Ruby and almost no spec testing in Ruby. Are there any guides or best practices that might help me out? |
I'm not sure there's a guide that would help you with this specific issue. But I think it will make things clearer to explicitly re-define |
The variable assignments in ArgParser do nothing, so remove them.
@courajs Is something like this what you're looking for? it 'creates draft in specified source directory' do
site_dir = 'site'
path = Pathname.new source_dir(site_dir, '_drafts', 'a-test-post.md')
expect(path).not_to exist
capture_stdout { described_class.process(args, 'source' => site_dir) }
expect(path).to exist
end |
Ah, I didn't realize the |
Jekyll Compose assumes that the Jekyll code lives in the root directory, so if you have custom source set in your config, it won't respect that.
I've updated compose to load in configuration (adding both
--config
and--source
options).