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

- old
+ new

@@ -41,42 +41,38 @@ rescue => e Rails.logger.warn "[sewing_kit] could not read manifest from #{@metadata_path}; falling back to node. #{e}" @metadata_path = nil end - result = SewingKit::Webpack::Manifest::Base.load_metadata_from_node + result = load_metadata_from_node metadata = normalize_metadata(result) @metadata_path = metadata && metadata['path'] metadata end - def load_metadata_from_fs(path) - begin - json_str = File.read(path) - rescue => e - raise ManifestLoadError.new(path, e) - end + private - begin - JSON.parse(json_str) - rescue => e - raise ManifestParseError, e - end - end - - protected - def normalize_metadata(maybe_array_metadata) if maybe_array_metadata.is_a?(Array) maybe_array_metadata.last else maybe_array_metadata end end - def mode - 'development' + def load_metadata_from_node + begin + stdout, stderr, status = Open3.capture3( + 'node_modules/.bin/sewing-kit', 'manifest', "--mode=development" + ) + rescue => e + raise NodeSewingKitNotRunnable.new('development', e) + end + + raise NodeSewingKitManifestMissing, stderr unless status.success? + + parse_metadata(stdout) end end class OnlyUseInProductionError < StandardError def initialize