Module: Ronin::Payloads::Mixins::TypeScript
- Defined in:
- lib/ronin/payloads/mixins/typescript.rb
Overview
A mixin for compiling TypeScript into JavaScript.
Class Method Summary collapse
-
.included(payload_class) ⇒ Object
Adds the
tsc
param to the payload class. -
.tsc ⇒ String
The default
tsc
compiler.
Instance Method Summary collapse
-
#compile_ts(*source_files) ⇒ Object
(also: #compile)
Compiles one or more source files.
Class Method Details
.included(payload_class) ⇒ Object
Adds the tsc
param to the payload class.
46 47 48 49 50 |
# File 'lib/ronin/payloads/mixins/typescript.rb', line 46 def self.included(payload_class) payload_class.param :tsc, required: true, default: -> { tsc }, desc: 'The TypeScript compiler to use' end |
.tsc ⇒ String
The default tsc
compiler.
36 37 38 |
# File 'lib/ronin/payloads/mixins/typescript.rb', line 36 def self.tsc ENV['TSC'] || 'tsc' end |
Instance Method Details
#compile_ts(*source_files) ⇒ Object Also known as: compile
Compiles one or more source files.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ronin/payloads/mixins/typescript.rb', line 63 def compile_ts(*source_files) args = [params[:tsc]] args.concat(source_files) case system(*args) when false raise(BuildFailed,"tsc command failed: #{args.join(' ')}") when nil raise(BuildFailed,"tsc command not installed") end end |