@@ -3,15 +3,16 @@ import { cat, exec, mkdir, rm } from 'shelljs'
33import { SubmissionJob , SubmissionResult } from '../types/job'
44import * as path from 'path'
55import * as fs from 'fs'
6- import http from 'http '
6+ import * as https from 'https '
77import { Scenario } from 'types/scenario.js'
8+ import { ClientRequest } from 'http' ;
89
9- export const download = ( url : string , dest : string ) : Promise < http . ClientRequest > => {
10+ export const download = ( url : string , dest : string ) : Promise < ClientRequest > => {
1011 const file = fs . createWriteStream ( dest ) ;
1112 return new Promise ( ( resolve , reject ) =>
12- http . get ( url , function ( response ) {
13+ https . get ( url , function ( response ) {
1314 response . pipe ( file ) ;
14- file . on ( 'finish' , function ( ) {
15+ file . on ( 'finish' , function ( ) {
1516 resolve ( )
1617 } ) ;
1718 } ) . on ( 'error' , err => {
@@ -24,16 +25,6 @@ class SubmissionScenario implements Scenario {
2425 setup ( currentJobDir : string , job : SubmissionJob ) {
2526 const LANG_CONFIG = config . LANGS [ job . lang ]
2627
27- job . testcases . map ( testcase => {
28- mkdir ( '-p' , `currentJobDir/${ testcase . id } ` )
29- // const file = fs.createWriteStream();
30- Promise . all ( [ http . get ( testcase . input ) , http . get ( testcase . output ) ] )
31- . then ( values => {
32- values . map ( value => {
33-
34- } )
35- } )
36- } )
3728 fs . writeFileSync ( path . join ( currentJobDir , LANG_CONFIG . SOURCE_FILE ) ,
3829 ( new Buffer ( job . source , 'base64' ) ) . toString ( 'ascii' ) )
3930 fs . writeFileSync ( path . join ( currentJobDir , ) ,
@@ -42,9 +33,11 @@ class SubmissionScenario implements Scenario {
4233
4334 async result ( currentJobDir : string ) : Promise < SubmissionResult > {
4435 // TODO
45- return {
46-
47- }
36+ return Promise . resolve ( {
37+ id : 1 ,
38+ stderr : '' ,
39+ testcases : [ ]
40+ } )
4841 }
4942}
5043
0 commit comments