Fix #5233: Increase our ability to detect Windows. #5235

Merged
merged 1 commit into from Sep 7, 2016

Projects

None yet

6 participants

@envygeeks
Member

This increases our ability to detect Windows, and to detect Windows+Bash. It also adds a message to Windows for users who try to "--watch", also noting to to them to check out the Windows ticket so eventually somebody pings us if this issue is fixed. /cc @TAGraves

/cc @jekyll/windows @jekyll/core @parkr @benbalter @jekyll/build

@envygeeks envygeeks added this to the 3.2.2 milestone Aug 12, 2016
@parkr parkr and 1 other commented on an outdated diff Aug 12, 2016
lib/jekyll/utils/platforms.rb
@@ -13,18 +13,40 @@ module Platforms
end
end
+ #
+
+ def windows?
+ !!(RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i || \
+ proc_version =~ %r!microsoft!i)
+ end
+
+ #
+
+ def linux?
+ RbConfig::CONFIG["host_host"] =~ %r!linux! && \
+ !proc_version =~ %r!microsoft!i
@parkr
parkr Aug 12, 2016 Member

I might be remembering Lua, but is this !~?

@envygeeks
envygeeks Aug 12, 2016 Member

You're right, I was in a hurry and doing it on my tablet, I'll ship a correction.

@parkr
Member
parkr commented Aug 12, 2016

Love it!!!!!

@XhmikosR XhmikosR and 2 others commented on an outdated diff Aug 12, 2016
lib/jekyll/utils/platforms.rb
@@ -13,18 +13,44 @@ module Platforms
end
end
+ #
+
+ def windows?
+ !!(RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i || \
@XhmikosR
XhmikosR Aug 12, 2016 Contributor

How about x64_mingw? Does this work right there?

@ghost
ghost Aug 12, 2016

Looks to me like the regex isn't anchored so it'd match x64_mingw

@envygeeks
envygeeks Aug 16, 2016 Member

@XhmikosR @spudowiar we don't care if it's x64, as @spudowiar pointed out, that's why it's unanchored, we are only interested if we find a specific keyword. There could be dozens of builds.

@XhmikosR
XhmikosR Aug 16, 2016 Contributor

As long as it detects x64_mingw as Windows, that's fine.

@benbalter benbalter and 1 other commented on an outdated diff Aug 12, 2016
lib/jekyll/commands/build.rb
@@ -71,12 +71,23 @@ def build(site, options)
#
# Returns nothing.
def watch(site, options)
- External.require_with_graceful_fail "jekyll-watch"
- watch_method = Jekyll::Watcher.method(:watch)
- if watch_method.parameters.size == 1
- watch_method.call(options)
+ if Utils::Platforms.windows?
+ Jekyll.logger.warn "", "--watch unsupported on Windows. "
@benbalter
benbalter Aug 12, 2016 edited Contributor

Maybe "The --watch flag is unsupported..." for a bit of polish?

@envygeeks
Member

Updated to add #really_windows? so that @ashmaroli can skip certain tests if it's actually Windows.

@ashmaroli ashmaroli and 1 other commented on an outdated diff Aug 16, 2016
lib/jekyll/utils/platforms.rb
define_method k do
!!(
RbConfig::CONFIG["host_os"] =~ v
)
end
end
+
+ #
+
+ private
+ def proc_version
+ @cacahed_proc_version ||= begin
@ashmaroli
ashmaroli Aug 16, 2016 Contributor

did you intend it to be @cached_proc_version ?

@envygeeks envygeeks Fix #5233: Increase our ability to detect Windows.
This increases our ability to detect Windows, and to detect Windows+Bash.  It also adds a message to Windows for users who try to "--watch", also noting to to them to check out the Windows ticket so eventually somebody pings us if this issue is fixed. /cc @TAGraves
f1f8319
@envygeeks
Member
@parkr
Member
parkr commented Aug 25, 2016

LGTM. Any objections from @jekyll/windows?

@envygeeks
Member

LGTM.

@envygeeks
Member

From our own Windows users this works for them, so it has a LGTM.

@parkr
Member
parkr commented Sep 7, 2016

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit dddafcc into master Sep 7, 2016

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jekyll/lgtm Approved by @parkr and @envygeeks.
@jekyllbot jekyllbot deleted the update-windows-detection-to-check-proc-version branch Sep 7, 2016
@parkr parkr added the windows label Sep 7, 2016
@parkr parkr modified the milestone: 3.2.2, 3.3 Sep 20, 2016
@ashmaroli
Contributor

@envygeeks, is there a way to detect Windows version or detect if I'm on the default Windows cmd.exe instead of bash shell? I miss autoregeneration now..
It works properly when using Jekyll 3.2.1 in cmd.exe on Windows 7.

@envygeeks
Member

@ashmaroli we do detect tell the difference between BashOnWindows and Windows itself in cmd.exe/PowerShell, the problem is probably in my detector which is a bit extreme in it's handling, it excludes the entirety of Windows even if there is the win32 extension that works with our watchers.

Later today after I get done with some stuff I'll ship a pull that adds bash_on_windows? and adjusts https://github.com/jekyll/jekyll/pull/5235/files#diff-47014fa0275ac66de0d2217d362529ffR74 to use that method so that watchers still work on normal Windows in cmd/PowerShell.

@ashmaroli
Contributor

Awesome!! Thanks 😃

@parkr
Member
parkr commented Oct 5, 2016

@envygeeks Planning to release 3.3 tomorrow so if you want that change in 3.3, we'll need the pull today. If not, then we can release later.

@envygeeks
Member

I'll push it sometime this evening after I get done working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment