Module: SourceMapsFixer::ReplaceLinksWithPredicted

Defined in:
lib/source_maps_fixer.rb

Class Method Summary collapse

Class Method Details

.callObject



32
33
34
35
36
37
38
39
40
# File 'lib/source_maps_fixer.rb', line 32

def call
  Path.files_with_source_maps.each do |asset_path, sm_path|
    new_content = File.read(asset_path).sub(
      Path.source_mapping_url(File.basename(sm_path)),
      "#{Path.source_mapping_url(Path.digest_path(sm_path))}\n\n"
    )
    File.write(asset_path, new_content)
  end
end

.undoObject



42
43
44
45
46
47
48
49
50
# File 'lib/source_maps_fixer.rb', line 42

def undo
  Path.files_with_source_maps.each do |asset_path, sm_path|
    new_content = File.read(asset_path).sub(
      "#{Path.source_mapping_url(Path.digest_path(sm_path))}\n\n",
      Path.source_mapping_url(File.basename(sm_path))
    )
    File.write(asset_path, new_content)
  end
end