nanoc-webpack.rb 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/nanoc/webpack/filter.rb +6 -5
- data/lib/nanoc/webpack/spawn.rb +23 -10
- data/lib/nanoc/webpack/version.rb +1 -1
- data/nanoc-webpack.rb.gemspec +2 -1
- data/spec/filter_spec.rb +5 -9
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50fc64dec9fe69f4f196e037ad4e29e9a18d9e29956779a0e875ebabbc2ac92e
|
4
|
+
data.tar.gz: df3d60655db70549e3063fc134e47c2627055ed2e2bbfdf64c7e5c3f6fab7a21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebe00cd6038a0afd6ef57dcb9bdaeae7f28b82ff5ea29e3b68a9d7d65bda3099c9af9f63211c5545011e5ad6cebbec7147a05c604ef6dac673776effdc58e7b6
|
7
|
+
data.tar.gz: ca7b8ea7060494597f1005724df564bcf955cd27ad7aef313053bb0e7f01469d7f2b2836a6eacf4f947d3146cb076001c9bd71219787b08ca609f2016867ca07
|
data/README.md
CHANGED
@@ -58,10 +58,10 @@ end
|
|
58
58
|
|
59
59
|
**Option: argv**
|
60
60
|
|
61
|
-
The `argv` option forwards command
|
61
|
+
The `argv` option forwards command line arguments directly
|
62
62
|
to the webpack executable. <br>
|
63
63
|
[Nanoc::Webpack.default_argv](https://0x1eef.github.io/x/nanoc-webpack.rb/Nanoc/Webpack.html#default_argv-class_method)
|
64
|
-
returns the default command
|
64
|
+
returns the default command line arguments forwarded to webpack:
|
65
65
|
|
66
66
|
```ruby
|
67
67
|
# Rules
|
@@ -76,10 +76,15 @@ end
|
|
76
76
|
|
77
77
|
**Rubygems.org**
|
78
78
|
|
79
|
-
nanoc-webpack.rb can be installed via rubygems.org
|
79
|
+
nanoc-webpack.rb can be installed via rubygems.org
|
80
80
|
|
81
81
|
gem install nanoc-webpack.rb
|
82
82
|
|
83
|
+
## See also
|
84
|
+
|
85
|
+
* [0x1eef/terry.reflectslight.io](https://github.com/0x1eef/terry.reflectslight.io) <br>
|
86
|
+
A simple nanoc application that uses nanoc-webpack.rb
|
87
|
+
|
83
88
|
## Sources
|
84
89
|
|
85
90
|
* [GitHub](https://github.com/0x1eef/nanoc-webpack.rb#readme)
|
data/lib/nanoc/webpack/filter.rb
CHANGED
@@ -14,21 +14,23 @@ module Nanoc::Webpack
|
|
14
14
|
type :text
|
15
15
|
|
16
16
|
##
|
17
|
+
# The default argv for webpack
|
18
|
+
#
|
17
19
|
# @example
|
18
20
|
# Nanoc::Webpack.default_argv.concat ["--cache-type", "filesystem"]
|
19
21
|
#
|
20
22
|
# @return [Array<String>]
|
21
|
-
#
|
23
|
+
# Default argv for webpack
|
22
24
|
def self.default_argv
|
23
25
|
@default_argv ||= []
|
24
26
|
end
|
25
27
|
|
26
28
|
##
|
27
29
|
# @param [String] content
|
28
|
-
# The contents of a file
|
30
|
+
# The contents of a file
|
29
31
|
#
|
30
32
|
# @param [Hash] options
|
31
|
-
# A hash of options
|
33
|
+
# A hash of options
|
32
34
|
#
|
33
35
|
# @return [void]
|
34
36
|
def run(content, options = {})
|
@@ -43,8 +45,7 @@ module Nanoc::Webpack
|
|
43
45
|
*argv,
|
44
46
|
"--entry", File.join(Dir.getwd, item.attributes[:content_filename]),
|
45
47
|
"--output-path", File.dirname(path),
|
46
|
-
"--output-filename", File.basename(path)]
|
47
|
-
log: File.join(tmpdir, "webpack.log")
|
48
|
+
"--output-filename", File.basename(path)]
|
48
49
|
File.read(path)
|
49
50
|
ensure
|
50
51
|
rm(path)
|
data/lib/nanoc/webpack/spawn.rb
CHANGED
@@ -1,17 +1,30 @@
|
|
1
1
|
module Nanoc::Webpack
|
2
2
|
module Spawn
|
3
|
+
require "test-cmd"
|
3
4
|
Error = Class.new(RuntimeError)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
|
6
|
+
##
|
7
|
+
# Spawns a process
|
8
|
+
#
|
9
|
+
# @param [String] exe
|
10
|
+
# The path to an executable
|
11
|
+
#
|
12
|
+
# @param [Array<String>] argv
|
13
|
+
# An array of command line arguments
|
14
|
+
#
|
15
|
+
# @return [Integer]
|
16
|
+
# Returns the exit code of the spawned process
|
17
|
+
def spawn(exe, argv)
|
18
|
+
r = cmd(exe, *argv)
|
19
|
+
if r.success?
|
20
|
+
r.exit_status
|
21
|
+
else
|
10
22
|
raise Error,
|
11
|
-
"#{File.basename(exe)} exited unsuccessfully
|
12
|
-
"(
|
13
|
-
"
|
14
|
-
"
|
23
|
+
"#{File.basename(exe)} exited unsuccessfully\n" \
|
24
|
+
"(item: #{item.identifier})\n" \
|
25
|
+
"(exit code: #{r.exit_status})\n" \
|
26
|
+
"(stdout: #{r.stdout.gsub(Dir.getwd, '')[1..]&.chomp})\n" \
|
27
|
+
"(stderr: #{r.stderr.gsub(Dir.getwd, '')[1..]&.chomp})\n",
|
15
28
|
[]
|
16
29
|
end
|
17
30
|
end
|
data/nanoc-webpack.rb.gemspec
CHANGED
@@ -10,9 +10,10 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.licenses = ["0BSD"]
|
11
11
|
gem.files = `git ls-files`.split($/)
|
12
12
|
gem.require_paths = ["lib"]
|
13
|
-
gem.summary = "nanoc-webpack.rb
|
13
|
+
gem.summary = "nanoc-webpack.rb = nanoc + webpack"
|
14
14
|
gem.description = gem.summary
|
15
15
|
gem.add_runtime_dependency "ryo.rb", "~> 0.5"
|
16
|
+
gem.add_runtime_dependency "test-cmd.rb", "~> 0.12.2"
|
16
17
|
gem.add_development_dependency "yard", "~> 0.9"
|
17
18
|
gem.add_development_dependency "redcarpet", "~> 3.5"
|
18
19
|
gem.add_development_dependency "rspec", "~> 3.10"
|
data/spec/filter_spec.rb
CHANGED
@@ -127,33 +127,29 @@ RSpec.describe Nanoc::Webpack::Filter do
|
|
127
127
|
[
|
128
128
|
"--entry", File.join(Dir.getwd, "test.ts"),
|
129
129
|
"--output-path", instance_of(String),
|
130
|
-
"--output-filename", instance_of(String)
|
130
|
+
"--output-filename", instance_of(String)
|
131
131
|
]
|
132
132
|
end
|
133
133
|
|
134
134
|
context "with default arguments" do
|
135
135
|
it "executes nodejs" do
|
136
|
-
expect(
|
136
|
+
expect(filter).to receive(:cmd).with(
|
137
137
|
"node",
|
138
138
|
"./node_modules/webpack/bin/webpack.js",
|
139
139
|
*cmdline,
|
140
|
-
|
141
|
-
)
|
142
|
-
expect(Process).to receive(:wait)
|
140
|
+
).and_return(Ryo('success?' => true))
|
143
141
|
filter.run(item)
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
147
145
|
context "with --no-cache" do
|
148
146
|
it "executes nodejs with an argument" do
|
149
|
-
expect(
|
147
|
+
expect(filter).to receive(:cmd).with(
|
150
148
|
"node",
|
151
149
|
"./node_modules/webpack/bin/webpack.js",
|
152
150
|
"--no-cache",
|
153
151
|
*cmdline,
|
154
|
-
|
155
|
-
)
|
156
|
-
expect(Process).to receive(:wait)
|
152
|
+
).and_return(Ryo('success?' => true))
|
157
153
|
filter.run(item, argv: ["--no-cache"])
|
158
154
|
end
|
159
155
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-webpack.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ryo.rb
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-cmd.rb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.12.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: yard
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +108,7 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '2.11'
|
97
|
-
description: nanoc-webpack.rb
|
111
|
+
description: nanoc-webpack.rb = nanoc + webpack
|
98
112
|
email:
|
99
113
|
- 0x1eef@protonmail.com
|
100
114
|
executables: []
|
@@ -141,5 +155,5 @@ requirements: []
|
|
141
155
|
rubygems_version: 3.5.9
|
142
156
|
signing_key:
|
143
157
|
specification_version: 4
|
144
|
-
summary: nanoc-webpack.rb
|
158
|
+
summary: nanoc-webpack.rb = nanoc + webpack
|
145
159
|
test_files: []
|