@@ -41,23 +41,49 @@ module.exports.parseStd = parseStd
4141 * @param {String } stdout Command's stdout output
4242 * @param {String } stderr Command's stderr output
4343 */
44- const progress = ( socket , originalMessage , stdout , stderr ) => {
44+ const progress = async ( socket , originalMessage , stdout , stderr , date ) => {
4545 console . log ( ' || STDOUT/ERR. Reporting...' . yellow )
4646
4747 const res = Object . assign ( originalMessage , {
4848 stdout : parseStd ( stdout ) ,
49- stderr : parseStd ( stderr )
49+ stderr : parseStd ( stderr ) ,
50+ date : date || null
5051 } )
5152
5253 // Make sure the agent doesn't make a report to the server, unless there's
5354 // an actual std output to be reported.
5455 if ( ! res . stdout && ! res . stderr ) { return }
5556
56- socket . emit ( 'tf.notify.progress' , res )
57+ await socket . emit ( 'tf.notify.progress' , res )
5758}
5859
5960module . exports . progress = progress
6061
62+ /**
63+ * Reports the final result of an execution, with
64+ * all stds as an array
65+ *
66+ * @param {Object } socket Socket's io socket that requested the execution
67+ * @param {Object } originalMessage Message that originally requested the execution
68+ * @param {object } result Command's stds and exit code output:
69+ *
70+ * {
71+ * stdLines: [{
72+ * output: string,
73+ * err: boolean,
74+ * date: date
75+ * }],
76+ * code: number
77+ * }
78+ */
79+ const bulkResult = async ( socket , originalMessage , result ) => {
80+ console . log ( ' || BULK STDOUT/ERR. Reporting...' . yellow )
81+ const res = Object . assign ( originalMessage , result )
82+ await socket . emit ( 'tf.notify.finishBulk' , res )
83+ }
84+
85+ module . exports . bulkResult = bulkResult
86+
6187/**
6288 * Reports the final result of an execution.
6389 *
0 commit comments