Skip to content

Commit a504beb

Browse files
committed
Prevent module exporter from inserting trailing whitespaces
1 parent 392e83d commit a504beb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

stub/module-exporter/export.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env ruby
22

3+
# Customize this name
4+
module_name = "Org"
5+
36
module JSExporter
47
class Sorter
58
def initialize()
@@ -88,18 +91,27 @@ def normalize_path(path)
8891
end
8992
end
9093

91-
module_name = "Org"
92-
9394
exporter = JSExporter::Exporter.new(ARGV)
9495
exporter.remove_depend_notations
95-
exported = exporter.sorted_contents.join("\n")
96+
sorted_contents = exporter.sorted_contents
9697

9798
puts <<EOS
9899
var #{module_name} = (function () {
99100
var exports = {};
100101
101102
EOS
102-
puts exported.split("\n").map { |line| " " + line }.join("\n")
103+
104+
puts sorted_contents.map { |content|
105+
# Add indentation
106+
content.split("\n").map { |line|
107+
if line == ""
108+
line
109+
else
110+
" " + line
111+
end
112+
}.join("\n") + "\n"
113+
}.join("\n")
114+
103115
puts <<EOS
104116
105117
return exports;

0 commit comments

Comments
 (0)