diff --git a/lib/tasks/generate.rake b/lib/tasks/generate.rake index 591e139..db0e065 100644 --- a/lib/tasks/generate.rake +++ b/lib/tasks/generate.rake @@ -1,6 +1,19 @@ namespace :typelizer do desc "Generate TypeScript interfaces from serializers" task generate: :environment do + benchmark do + Typelizer::Generator.call + end + end + + desc "Removes all files in output folder and refreshs all generate TypeScript interfaces from serializers" + task "generate:refresh": :environment do + benchmark do + Typelizer::Generator.call(force: true) + end + end + + def benchmark(&block) require "benchmark" ENV["DISABLE_TYPELIZER"] = "false" @@ -8,7 +21,7 @@ namespace :typelizer do puts "Generating TypeScript interfaces..." serializers = [] time = Benchmark.realtime do - serializers = Typelizer::Generator.call + serializers = block.call end puts "Finished in #{time} seconds" diff --git a/lib/typelizer/generator.rb b/lib/typelizer/generator.rb index f2ebde5..9ac4224 100644 --- a/lib/typelizer/generator.rb +++ b/lib/typelizer/generator.rb @@ -2,8 +2,8 @@ module Typelizer class Generator - def self.call - new.call + def self.call(**args) + new.call(**args) end def initialize(config = Typelizer::Config)