js_dependency 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 201aa2538971ea1e938c32236410e2b31ada21abbcd9f90141b84b08b132e7bb
4
- data.tar.gz: fd6c9eb934ea1f884f885e0bce39c989ab2536a10faa33f900bcc95418f41fa6
3
+ metadata.gz: eed9f17f75fff9405d112f14ac2cccffffa9ecce728c718ff9a14eda3396c5ba
4
+ data.tar.gz: 645a8b5ab4363e2d1c4d7f6b25c79c0908d3f4a8ed78a928590c8d25e841c0e4
5
5
  SHA512:
6
- metadata.gz: 0641c8506997b0bf21e4ec9cede06096fbc9b523e8e4e39954bb4a63eb73d551772945efa73c7e1098b0481cf70b0fc87eb291140f57db6b7599901b958a1b78
7
- data.tar.gz: c0c38b6e23cb29d54a40009aba2290543d9706366eb45a092cbbd4e47817972e161e0830bbc51081e76bbd85899247d02bf851345030126c715e2e4e6e2d6e8e
6
+ metadata.gz: 2b1160dfd6319369750cf8d10feffd4b703aa72ba1d0199e5e1e9bb341316beda0a07e7982f83675435e9642edd29fd999d5953c32c5f90aa95b2b81322f8ed8
7
+ data.tar.gz: ff0eb122ee309e0ba743c5c422e6ff21641e04131d5ec3da650781ec2e22f6878cbeaf2e006e03fc68dd170d64b80ca5d91471fa3259d4b4384bb67d9853782a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.7] - 2022-08-11
4
+
5
+ - If target is index.js, orphan include in analysis.
6
+
3
7
  ## [0.3.6] - 2022-08-11
4
8
 
5
9
  - Add src path in script tag for create index.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- js_dependency (0.3.6)
4
+ js_dependency (0.3.7)
5
5
  pathname
6
6
  thor
7
7
  yaml
@@ -30,11 +30,9 @@ module JsDependency
30
30
  # @param [String] target_path
31
31
  # @return [TrueClass, FalseClass]
32
32
  def orphan?(target_path)
33
- target_pathname = JsDependency::TargetPathname.new(target_path)
34
- paths = []
35
- target_pathname.each_parent_path(1, @index) do |parent_path, _child_path|
36
- paths << parent_path
37
- end
33
+ paths = parent_paths(target_path)
34
+ paths += dir_parent_paths(target_path) if target_path.include?("index.js")
35
+
38
36
  paths.size.zero?
39
37
  end
40
38
 
@@ -44,6 +42,30 @@ module JsDependency
44
42
  def relative_path_or_external_path(path, src_path)
45
43
  JsDependency::PathnameUtility.relative_path_or_external_path(path, src_path)
46
44
  end
45
+
46
+ # Parent paths.
47
+ # @param [String] target_path
48
+ # @return [Array<String>]
49
+ def parent_paths(target_path)
50
+ target_pathname = JsDependency::TargetPathname.new(target_path)
51
+ paths = []
52
+ target_pathname.each_parent_path(1, @index) do |parent_path, _child_path|
53
+ paths << parent_path
54
+ end
55
+ paths
56
+ end
57
+
58
+ # Directory parent paths.
59
+ # @param [String] target_path
60
+ # @return [Array<String>]
61
+ def dir_parent_paths(target_path)
62
+ paths = []
63
+ target_pathname_dir = JsDependency::TargetPathname.new(Pathname.new(target_path).dirname.to_s)
64
+ target_pathname_dir.each_parent_path(1, @index) do |parent_path, _child_path|
65
+ paths << parent_path
66
+ end
67
+ paths
68
+ end
47
69
  end
48
70
  end
49
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsDependency
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_dependency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - junara