File tree Expand file tree Collapse file tree 5 files changed +39
-7
lines changed Expand file tree Collapse file tree 5 files changed +39
-7
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " cpbooster" ,
33 "author" : " searleser97" ,
4- "version" : " 2.6.0 " ,
4+ "version" : " 2.6.3 " ,
55 "description" : " cpbooster is a cross-platform CLI tool designed to boost competitive programmer's speed during contests by automating various routine tasks" ,
66 "homepage" : " https://github.com/searleser97/cpbooster" ,
77 "repository" : " github:searleser97/cpbooster" ,
2626 "test" : " jest" ,
2727 "lint" : " eslint . --ext .ts" ,
2828 "lint-and-fix" : " eslint . --ext .ts --fix" ,
29- "prepublish" : " npm run build"
29+ "prepublish" : " npm run build" ,
30+ "version" : " npm run build"
3031 },
3132 "files" : [
3233 " *"
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export default class Config {
4040 // preferred language extension
4141 preferredLang : string ;
4242 hideTestCaseInput : boolean ;
43+ maxLinesToShowFromInput : number ;
4344 cloneInCurrentDir : boolean ;
4445 // config for language extension
4546 languages : Record < string , LangConfig | undefined > ;
@@ -53,6 +54,7 @@ export default class Config {
5354 this . useUserDefaultBrowser = true ;
5455 this . preferredLang = "cpp" ;
5556 this . hideTestCaseInput = false ;
57+ this . maxLinesToShowFromInput = 50 ;
5658 this . cloneInCurrentDir = false ;
5759 this . languages = {
5860 cpp : {
Original file line number Diff line number Diff line change @@ -72,7 +72,11 @@ export default class CompiledTester extends Tester {
7272 const binaryFileName = this . getExecutableFileNameOrDefault ( true ) ;
7373 const binaryFilePath = `.${ Path . sep } ${ binaryFileName } ` ;
7474 if ( compile ) {
75- this . compile ( true ) ;
75+ const { status, feedback } = this . compile ( true ) ;
76+ if ( ! status ) {
77+ this . printTestResults ( Veredict . CE , feedback , testId ) ;
78+ exit ( 0 ) ;
79+ }
7680 } else if ( ! fs . existsSync ( binaryFilePath ) ) {
7781 console . log ( chalk . red ( "Error:" ) , `Executable ${ binaryFilePath } not found` ) ;
7882 exit ( 0 ) ;
@@ -84,7 +88,11 @@ export default class CompiledTester extends Tester {
8488 const binaryFileName = this . getExecutableFileNameOrDefault ( true ) ;
8589 const binaryFilePath = `.${ Path . sep } ${ binaryFileName } ` ;
8690 if ( compile ) {
87- this . compile ( true ) ;
91+ const { status, feedback } = this . compile ( true ) ;
92+ if ( ! status ) {
93+ this . printTestResults ( Veredict . CE , feedback , 0 ) ;
94+ exit ( 0 ) ;
95+ }
8896 } else if ( ! fs . existsSync ( binaryFilePath ) ) {
8997 console . log ( chalk . red ( "Error:" ) , `Executable ${ binaryFilePath } not found` ) ;
9098 exit ( 0 ) ;
Original file line number Diff line number Diff line change @@ -94,7 +94,11 @@ export default class MixedTester extends Tester {
9494 debugOne ( testId : number , compile : boolean ) : void {
9595 const executableFileName = this . getExecutableFileName ( ) ;
9696 if ( compile ) {
97- this . compile ( true ) ;
97+ const { status, feedback } = this . compile ( true ) ;
98+ if ( ! status ) {
99+ this . printTestResults ( Veredict . CE , feedback , testId ) ;
100+ exit ( 0 ) ;
101+ }
98102 } else if ( ! fs . existsSync ( executableFileName ) ) {
99103 console . log (
100104 chalk . red ( "Error:" ) ,
@@ -116,7 +120,11 @@ export default class MixedTester extends Tester {
116120 debugWithUserInput ( compile : boolean ) : void {
117121 const executableFileName = this . getExecutableFileName ( ) ;
118122 if ( compile ) {
119- this . compile ( true ) ;
123+ const { status, feedback } = this . compile ( true ) ;
124+ if ( ! status ) {
125+ this . printTestResults ( Veredict . CE , feedback , 0 ) ;
126+ exit ( 0 ) ;
127+ }
120128 } else if ( ! fs . existsSync ( executableFileName ) ) {
121129 console . log (
122130 chalk . red ( "Error:" ) ,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import Config from "../../Config/Config";
2020import { Veredict } from "../../Types/Veredict" ;
2121import Util from "../../Utils/Util" ;
2222import * as fs from "fs" ;
23+ import os from "os" ;
2324import { exit } from "process" ;
2425import chalk from "chalk" ;
2526import { spawnSync } from "child_process" ;
@@ -100,7 +101,19 @@ export default abstract class Tester {
100101 if ( ! this . config . hideTestCaseInput ) {
101102 const input = fs . readFileSync ( Tester . getInputPath ( this . filePath , testId ) ) . toString ( ) ;
102103 console . log ( `${ chalk . bgWhite ( chalk . black ( " Input " ) ) } \n` ) ;
103- console . log ( input + "\n" ) ;
104+ const inputLines = input . split ( / \n | \r \n / ) ;
105+ if (
106+ this . config . maxLinesToShowFromInput === 0 ||
107+ inputLines . length <= this . config . maxLinesToShowFromInput
108+ ) {
109+ console . log ( inputLines . join ( os . EOL ) + os . EOL ) ;
110+ } else {
111+ const reducedInputLines = [
112+ ...inputLines . slice ( 0 , this . config . maxLinesToShowFromInput ) ,
113+ "... (the rest of the input is hidden)"
114+ ] . join ( os . EOL ) ;
115+ console . log ( reducedInputLines + os . EOL ) ;
116+ }
104117 }
105118 } else {
106119 console . log ( this . getFormattedVeredict ( veredict ) + "\n" ) ;
You can’t perform that action at this time.
0 commit comments