-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcompile-exports.rb
More file actions
executable file
·61 lines (47 loc) · 1.21 KB
/
Copy pathcompile-exports.rb
File metadata and controls
executable file
·61 lines (47 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/ruby
#
# Generates coffeescript file used to export the library.
# Author: rbuckheit
#
JS_LIB_EXPORTS = [
'axios',
'base64',
'bluebird',
'forge',
'jscache',
'lodash',
'loglevel',
'murmurhash3',
'pako',
'revalidator',
'function-name'
]
EXPORT_FILE_PATH = 'js/src/kryptnostic.coffee'
COFFEE_FILES = `find js/src -name "*.coffee"`.split.reject{|c| c.end_with?(EXPORT_FILE_PATH)}
def get_relative_path(path)
return path.gsub('js/src/', '')
end
def remove_extension(file_name)
return file_name.chomp('.js').chomp('.coffee')
end
COFFEE_EXPORTS = COFFEE_FILES.map{|f| get_relative_path(f)}.map{|f| remove_extension(f)}.sort
EXPORT_FILE_CONTENT = """
#
# AUTO_GENERATED: #{Time.new.inspect}
# Pseudo-module which includes all modules exported as part of kryptnostic.
# This file is for optimizer build purposes only and should not be required or edited.
#
EXPORTED_MODULES = [
# library
# =======
#{JS_LIB_EXPORTS.map{|ln| "'#{ln}'"}.join("\n ")}
# kryptnostic
# ===========
#{COFFEE_EXPORTS.map{|c| "'cs!#{c}'"}.join("\n ")}
]
define('kryptnostic', EXPORTED_MODULES, (require) ->
'use strict'
return {}
)
"""
File.open(EXPORT_FILE_PATH, 'w'){|f| f.write(EXPORT_FILE_CONTENT)}