filters/webpack: remove "exe" option.

Fix #37
This commit is contained in:
0x1eef 2022-11-17 23:34:46 -03:00 committed by Robert
parent 516cbc5594
commit b7410acc07
3 changed files with 11 additions and 9 deletions

View file

@ -22,5 +22,7 @@ Style/FrozenStringLiteralComment:
# Disabled cops (lib-specific)
Layout/MultilineMethodCallIndentation:
Enabled: false
Layout/ArgumentAlignment:
Enabled: false
Style/TrivialAccessors:
Enabled: false

6
Rules
View file

@ -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

View file

@ -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