node-runner 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -5
- data/README.md +11 -5
- data/bridgetown.automation.rb +29 -0
- data/lib/node-runner.rb +8 -4
- data/lib/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaadb4234b05108dec2d60b995df86e7546d3e2c1a62022c796f5c62a552e83c
|
4
|
+
data.tar.gz: ec76ab4ac759104ed00877d622e3fe4dedcebff0aa7c16108a60c9b26abd4d54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59c70fa43ebefeefa2fb8b3110e780a87d0d986bac41063714196ce4e9da1673113d8cf1ef1138fd45a02aba3128a8b2383933c5a66d82f3d7673d35059a40b9
|
7
|
+
data.tar.gz: ddfec3af8f70482c3e8a7f539b7aa5e13c227a9dbeed00a427b2c3419a8c04ce7b1f5166a2fdfa512b11d939c47878d98b143bf93a3c372a755d3b008bb215d9
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## Unreleased
|
4
4
|
|
5
|
-
|
5
|
+
...
|
6
6
|
|
7
|
-
|
7
|
+
## 1.1.0 / 2021-10-17
|
8
8
|
|
9
|
-
|
9
|
+
- fix: windows support for extensions [#1](https://github.com/bridgetownrb/node-runner/pull/1) ([bglw](https://github.com/bglw))
|
10
|
+
|
11
|
+
## 1.0.1 / 2020-05-09
|
12
|
+
|
13
|
+
- Set the NODE_ENV so local modules can be found.
|
14
|
+
|
15
|
+
## 1.0.0 / 2020-04-29
|
16
|
+
|
17
|
+
- Initial release of NodeRunner.
|
data/README.md
CHANGED
@@ -12,6 +12,12 @@ Run this command to add this plugin to your project's Gemfile:
|
|
12
12
|
$ bundle add node-runner
|
13
13
|
```
|
14
14
|
|
15
|
+
For [Bridgetown](https://www.bridgetownrb.com) websites (requires v0.15 or later), you can run an automation to install NodeRunner and set up a builder plugin for further customization.
|
16
|
+
|
17
|
+
```shell
|
18
|
+
bundle exec bridgetown apply https://github.com/bridgetownrb/node-runner
|
19
|
+
```
|
20
|
+
|
15
21
|
## Usage
|
16
22
|
|
17
23
|
Simply create a new `NodeRunner` object and pass in the Javascript code you wish to
|
@@ -21,11 +27,11 @@ execute:
|
|
21
27
|
require "node-runner"
|
22
28
|
|
23
29
|
runner = NodeRunner.new(
|
24
|
-
<<~
|
30
|
+
<<~JAVASCRIPT
|
25
31
|
const hello = (response) => {
|
26
|
-
return `Hello? ${response}
|
32
|
+
return `Hello? ${response}`
|
27
33
|
}
|
28
|
-
|
34
|
+
JAVASCRIPT
|
29
35
|
)
|
30
36
|
```
|
31
37
|
|
@@ -44,12 +50,12 @@ You can also use Node require statements in your Javascript:
|
|
44
50
|
|
45
51
|
```ruby
|
46
52
|
runner = NodeRunner.new(
|
47
|
-
<<~
|
53
|
+
<<~JAVASCRIPT
|
48
54
|
const path = require("path")
|
49
55
|
const extname = (filename) => {
|
50
56
|
return path.extname(filename);
|
51
57
|
}
|
52
|
-
|
58
|
+
JAVASCRIPT
|
53
59
|
)
|
54
60
|
|
55
61
|
extname = runner.extname("README.md")
|
@@ -0,0 +1,29 @@
|
|
1
|
+
run "bundle add node-runner", abort_on_failure: false
|
2
|
+
|
3
|
+
builder_file = "node_script_builder.rb"
|
4
|
+
create_builder builder_file do
|
5
|
+
<<~RUBY
|
6
|
+
require "node-runner"
|
7
|
+
|
8
|
+
class NodeScriptBuilder < SiteBuilder
|
9
|
+
def build
|
10
|
+
# access output in Liquid with {{ site.data.node_script.hello }}
|
11
|
+
add_data "node_script" do
|
12
|
+
runner = NodeRunner.new(
|
13
|
+
<<~JAVASCRIPT
|
14
|
+
const hello = (response) => {
|
15
|
+
return `Hello? ${response}`
|
16
|
+
}
|
17
|
+
JAVASCRIPT
|
18
|
+
)
|
19
|
+
|
20
|
+
{
|
21
|
+
hello: runner.hello("Goodbye!")
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
RUBY
|
27
|
+
end
|
28
|
+
|
29
|
+
say_status "node-runner", "Installed! Check out plugins/builders/#{builder_file} to customize your Node script"
|
data/lib/node-runner.rb
CHANGED
@@ -117,16 +117,20 @@ class NodeRunner::Executor
|
|
117
117
|
|
118
118
|
def locate_executable(command)
|
119
119
|
commands = Array(command)
|
120
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
121
|
+
exts << ''
|
120
122
|
|
121
123
|
commands.find { |cmd|
|
122
124
|
if File.executable? cmd
|
123
125
|
cmd
|
124
126
|
else
|
125
|
-
path = ENV['PATH'].split(File::PATH_SEPARATOR).
|
126
|
-
|
127
|
-
|
127
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR).flat_map { |p|
|
128
|
+
exts.map { |e| File.join(p, "#{cmd}#{e}") }
|
129
|
+
}.find { |p|
|
130
|
+
File.executable?(p) && File.file?(p)
|
128
131
|
}
|
129
|
-
|
132
|
+
|
133
|
+
path && File.expand_path(path)
|
130
134
|
end
|
131
135
|
}
|
132
136
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: maintainers@bridgetownrb.com
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- LICENSE.txt
|
23
23
|
- README.md
|
24
24
|
- Rakefile
|
25
|
+
- bridgetown.automation.rb
|
25
26
|
- lib/node-runner.rb
|
26
27
|
- lib/node_runner.js
|
27
28
|
- lib/version.rb
|
@@ -45,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
46
|
- !ruby/object:Gem::Version
|
46
47
|
version: '0'
|
47
48
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
49
|
+
rubygems_version: 3.1.4
|
49
50
|
signing_key:
|
50
51
|
specification_version: 4
|
51
52
|
summary: A simple way to execute Javascript in a Ruby context via Node
|