lib/sewing_kit/webpack/manifest/base.rb in sewing_kit-0.91.0 vs lib/sewing_kit/webpack/manifest/base.rb in sewing_kit-0.92.0

- old
+ new

@@ -33,27 +33,27 @@ else current_metadata['assets'] end end - def self.load_metadata_from_node - begin - stdout, stderr, status = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}") - rescue => e - raise NodeSewingKitNotRunnable.new(mode, e) - end + protected - raise NodeSewingKitManifestMissing.new(mode, stderr) unless status.success? - + def load_metadata_from_fs(path) begin - JSON.parse(stdout) + content = File.read(path) rescue => e - raise ManifestParseError, e + raise ManifestLoadError.new(path, e) end + + parse_metadata(content) end - def self.mode - ENV['NODE_ENV'] || Rails.env.to_s || 'production' + private + + def parse_metadata(json) + JSON.parse(json) + rescue => e + raise ManifestParseError, e end end end end end