Ver Fonte

[misc] CompileController: simplify composing of outputFiles

Jakob Ackermann há 5 anos atrás
pai
commit
fb3966ef35

+ 2 - 12
services/clsi/app/js/CompileController.js

@@ -123,7 +123,7 @@ module.exports = CompileController = {
                 stats,
                 timings,
                 outputFiles: outputFiles.map((file) => {
-                  const record = {
+                  return {
                     url:
                       `${Settings.apis.clsi.url}/project/${request.project_id}` +
                       (request.user_id != null
@@ -131,18 +131,8 @@ module.exports = CompileController = {
                         : '') +
                       (file.build != null ? `/build/${file.build}` : '') +
                       `/output/${file.path}`,
-                    path: file.path,
-                    type: file.type,
-                    build: file.build,
-                    contentId: file.contentId
+                    ...file
                   }
-                  if (file.ranges != null) {
-                    record.ranges = file.ranges
-                  }
-                  if (file.size != null) {
-                    record.size = file.size
-                  }
-                  return record
                 })
               }
             })

+ 2 - 10
services/clsi/test/unit/js/CompileControllerTests.js

@@ -157,11 +157,7 @@ describe('CompileController', function () {
               outputFiles: this.output_files.map((file) => {
                 return {
                   url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
-                  path: file.path,
-                  type: file.type,
-                  build: file.build,
-                  // gets dropped by JSON.stringify
-                  contentId: undefined
+                  ...file
                 }
               })
             }
@@ -202,11 +198,7 @@ describe('CompileController', function () {
               outputFiles: this.output_files.map((file) => {
                 return {
                   url: `${this.Settings.apis.clsi.url}/project/${this.project_id}/build/${file.build}/output/${file.path}`,
-                  path: file.path,
-                  type: file.type,
-                  build: file.build,
-                  // gets dropped by JSON.stringify
-                  contentId: undefined
+                  ...file
                 }
               })
             }