From b7410acc075f5ae1b22ecf8ce0c8f1d33662d98f Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 17 Nov 2022 23:34:46 -0300 Subject: [PATCH] filters/webpack: remove "exe" option. Fix #37 --- .rubocop.yml | 2 ++ Rules | 6 +++--- lib/filters/webpack.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a26b3b8..6ae31fa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,5 +22,7 @@ Style/FrozenStringLiteralComment: # Disabled cops (lib-specific) Layout/MultilineMethodCallIndentation: Enabled: false +Layout/ArgumentAlignment: + Enabled: false Style/TrivialAccessors: Enabled: false diff --git a/Rules b/Rules index 21bad85..eb01f51 100644 --- a/Rules +++ b/Rules @@ -53,7 +53,7 @@ end ## # /js/pages/surah.js compile "/js/pages/TheSurahPage.tsx" do - filter :webpack, exe: "./node_modules/webpack/bin/webpack.js" + filter :webpack write "/js/pages/surah.js" filter :gzip_text write "/js/pages/surah.js.gz" @@ -62,14 +62,14 @@ end ## # /js/pages/redirect-to-random-surah.js compile "/js/pages/redirect-to-random-surah.ts" do - filter :webpack, exe: "./node_modules/webpack/bin/webpack.js" + filter :webpack write "/js/pages/redirect-to-random-surah.js" end ## # /js/pages/redirect-to-surah-slug.js compile "/js/pages/redirect-to-surah-slug.ts" do - filter :webpack, exe: "./node_modules/webpack/bin/webpack.js" + filter :webpack write "/js/pages/redirect-to-surah-slug.js" end diff --git a/lib/filters/webpack.rb b/lib/filters/webpack.rb index 799db8b..8b53cf9 100644 --- a/lib/filters/webpack.rb +++ b/lib/filters/webpack.rb @@ -13,7 +13,7 @@ class Nanoc::Filter::Webpack < Nanoc::Filter def run(content, options = {}) file, dir = temp!(content, extname(item.identifier.to_s)) basename = basename_for(item.identifier.to_s) - run_webpack(options.dup.delete(:exe) || "webpack", file.path, basename) + webpack(file.path, basename) File.read(File.join(dir, basename)) .tap { file.tap(&:unlink).close @@ -33,12 +33,12 @@ class Nanoc::Filter::Webpack < Nanoc::Filter File.extname(path) end - def run_webpack(webpack_bin, path, basename) + def webpack(path, basename) system "node", - webpack_bin, - "--entry", path, - "--output-path", File.dirname(path), - "--output-filename", basename + "./node_modules/webpack/bin/webpack.js", + "--entry", path, + "--output-path", File.dirname(path), + "--output-filename", basename exit! unless $?.success? end