diff --git a/.github/test.yml b/.github/test.yml new file mode 100644 index 0000000..fd315f9 --- /dev/null +++ b/.github/test.yml @@ -0,0 +1,23 @@ +--- +name: test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + entry: + - { ruby: '2.7' } + - { ruby: '3.0' } + - { ruby: '3.1' } + - { ruby: '3.2' } + name: test (${{ matrix.entry.ruby }}) + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.entry.ruby }} + - run: bundle install --jobs=3 --retry=3 --path=vendor/bundle + - run: bundle exec rake spec + continue-on-error: ${{ matrix.entry.allowed-failure }} diff --git a/README.md b/README.md index bbaa445..cbb74f9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Last Modified At Plugin +![Rake Status](https://github.com/gjtorikian/jekyll-last-modified-at/actions/workflows/test.yml/badge.svg) + + A liquid tag for Jekyll to indicate the last time a file was modified. This plugin determines a page's last modified date by checking the last Git commit date of source files. In the event Git is not available, the file's `mtime` is used. diff --git a/jekyll-last-modified-at.gemspec b/jekyll-last-modified-at.gemspec index 38146a4..aa889e0 100644 --- a/jekyll-last-modified-at.gemspec +++ b/jekyll-last-modified-at.gemspec @@ -11,7 +11,6 @@ Gem::Specification.new do |s| s.files = Dir['lib/**/*.rb'] s.add_dependency 'jekyll', '>= 3.7', ' < 5.0' - s.add_dependency 'posix-spawn', '~> 0.3.9' s.add_development_dependency 'rake' s.add_development_dependency 'rspec', '~> 3.4' diff --git a/lib/jekyll-last-modified-at/executor.rb b/lib/jekyll-last-modified-at/executor.rb index 6136e11..ccbadbf 100644 --- a/lib/jekyll-last-modified-at/executor.rb +++ b/lib/jekyll-last-modified-at/executor.rb @@ -1,36 +1,16 @@ # frozen_string_literal: true -require 'posix/spawn' +require 'open3' module Jekyll module LastModifiedAt module Executor - extend POSIX::Spawn def self.sh(*args) - r, w = IO.pipe - e, eo = IO.pipe - pid = spawn(*args, - :out => w, r => :close, - :err => eo, e => :close) - - if pid.positive? - w.close - eo.close - out = r.read - err = e.read - ::Process.waitpid(pid) - "#{out} #{err}".strip if out - end - ensure - [r, w, e, eo].each do |io| - begin - io.close - rescue StandardError - nil - end - end + stdout_str, stderr_str, status = Open3.capture3(*args) + return "#{stdout_str} #{stderr_str}".strip if status.success? end + end end end