elelem-tools 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/elelem/tools/verify.rb +27 -1
- data/lib/elelem/tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76ec7a010fbd709f164dbf2ac05b85bd60187e1451a6505726fc7f35dbd9d7eb
|
|
4
|
+
data.tar.gz: 74de74a8b6add422ef3db5ade2bb9f3eec63eb1373687e324145b2cd09de48c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 49fd1c98c79f4d45d6039d71347b6d96268a6bc10b594b96e9e4a24d54f863c4e0091fd457dfbd7e6bb3caca22bfda71b3c82c350cea2390b14173b81b271124
|
|
7
|
+
data.tar.gz: 8049db48ab2f0c0ca92b5db290e8827f2bc2f0f5eef144407872a4bd4f0ebe4850621610abf865ce0161e813edfb427a8a0a64e842fdc33c0027f4bb15c221db
|
data/lib/elelem/tools/verify.rb
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
Elelem::Plugins.register(:verify) do |agent|
|
|
4
|
+
class Verifiers
|
|
5
|
+
SYNTAX = {
|
|
6
|
+
".rb" => "ruby -c %{path}",
|
|
7
|
+
".erb" => "erb -x %{path} | ruby -c",
|
|
8
|
+
".py" => "python -m py_compile %{path}",
|
|
9
|
+
".go" => "go vet %{path}",
|
|
10
|
+
".rs" => "cargo check --quiet",
|
|
11
|
+
".ts" => "npx tsc --noEmit %{path}",
|
|
12
|
+
".js" => "node --check %{path}",
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
def self.for(path)
|
|
16
|
+
return [] unless path
|
|
17
|
+
|
|
18
|
+
cmds = []
|
|
19
|
+
ext = File.extname(path)
|
|
20
|
+
cmds << (SYNTAX[ext] % { path: path }) if SYNTAX[ext]
|
|
21
|
+
cmds << test_runner
|
|
22
|
+
cmds.compact
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.test_runner
|
|
26
|
+
%w[bin/test script/test].find { |s| File.executable?(s) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
4
30
|
agent.toolbox.add("verify",
|
|
5
31
|
description: "Verify file syntax and run tests",
|
|
6
32
|
params: { path: { type: "string" } },
|
|
7
33
|
required: ["path"]
|
|
8
34
|
) do |args|
|
|
9
35
|
path = args["path"]
|
|
10
|
-
|
|
36
|
+
Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
|
|
11
37
|
agent.terminal.say agent.toolbox.header("execute", { "command" => cmd })
|
|
12
38
|
v = agent.toolbox.run("execute", { "command" => cmd })
|
|
13
39
|
break v.merge(path: path, command: cmd) if v[:exit_status] != 0
|
data/lib/elelem/tools/version.rb
CHANGED