File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ $ npm install -g learnpack-python
19
19
$ oclif-example COMMAND
20
20
running command...
21
21
$ oclif-example (-v| --version| version)
22
- learnpack-python/0.0.34 darwin-x64 node-v10.17 .0
22
+ learnpack-python/0.0.35 darwin-x64 node-v14.16 .0
23
23
$ oclif-example --help [COMMAND]
24
24
USAGE
25
25
$ oclif-example COMMAND
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " learnpack-python" ,
3
3
"description" : " Python Compiler for learnpack tutorials" ,
4
- "version" : " 0.0.34 " ,
4
+ "version" : " 0.0.35 " ,
5
5
"author" : " Alejandro Sanchez @alesanchezr" ,
6
6
"bugs" : " https://github.com/learnpack/learnpack/issues" ,
7
7
"dependencies" : {
Original file line number Diff line number Diff line change @@ -10,17 +10,25 @@ module.exports = {
10
10
} ,
11
11
run : async function ( { exercise, socket } ) {
12
12
13
- let entryPath = exercise . entry || exercise . files . map ( f => './' + f . path ) . find ( f => f . indexOf ( 'app.py' ) > - 1 ) ;
13
+ let entryPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . includes ( exercise . entry || 'app.py' ) ) ;
14
14
if ( ! entryPath ) throw new Error ( "No entry file to compile, maybe you need to create an app.py in the exercise directory?" ) ;
15
15
16
16
const content = fs . readFileSync ( entryPath , "utf8" ) ;
17
- const count = Utils . getMatches ( / ^ ( [ ^ \/ ] ) + i n p u t \( (?: [ " ' ` ] { 1 } ( .* ) [ " ' ` ] { 1 } ) ? \) / gm, content ) ;
17
+ const count = Utils . getMatches ( / ^ (?: [ ^ \/ ] ) + i n p u t \s * \( \s * (?: [ " ' ` ] { 1 } ( .* ) [ " ' ` ] { 1 } ) ? \s * \) \s * / gm, content ) ;
18
18
let inputs = ( count . length == 0 ) ? [ ] : await socket . ask ( count ) ;
19
-
19
+
20
20
const result = await python . runFile ( entryPath , { stdin : inputs . join ( '\n' ) , executionPath : 'python3' } )
21
21
if ( result . exitCode > 0 ) throw CompilationError ( result . stderr ) ;
22
- return Utils . cleanStdout ( result . stdout , count )
22
+ return cleanStdout ( result . stdout , inputs )
23
23
24
24
} ,
25
25
}
26
-
26
+
27
+ const cleanStdout = ( buffer , inputs ) => {
28
+
29
+ // if(Array.isArray(inputs))
30
+ // for(let i = 0; i < inputs.length; i++)
31
+ // if(inputs[i]) buffer = buffer.replace(inputs[i],'');
32
+
33
+ return buffer ;
34
+ }
Original file line number Diff line number Diff line change @@ -51,10 +51,10 @@ def pytest_generate_tests(metafunc):
51
51
52
52
const getEntry = ( ) => {
53
53
//console.log(exercise);
54
- let entryPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . indexOf ( 'test.py' ) > - 1 || f . indexOf ( 'tests.py' ) > - 1 )
54
+ let entryPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . includes ( 'test.py' ) || f . includes ( 'tests.py' ) )
55
55
if ( ! fs . existsSync ( entryPath ) ) throw TestingError ( `🚫 No tests.py script found on the exercise in ${ entryPath } ` )
56
56
57
- const appPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . indexOf ( 'app.py' ) > - 1 )
57
+ const appPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . includes ( exercise . entry || 'app.py' ) )
58
58
if ( fs . existsSync ( appPath ) ) {
59
59
let content = fs . readFileSync ( appPath , "utf8" )
60
60
const count = Utils . getMatches ( / d e f \s [ a - z A - Z ] / gm, content )
@@ -73,7 +73,7 @@ def pytest_generate_tests(metafunc):
73
73
74
74
const getCommands = async function ( ) {
75
75
76
- const appPath = exercise . entry || exercise . files . map ( f => './' + f . path ) . find ( f => f . indexOf ( 'app.py' ) > - 1 )
76
+ const appPath = exercise . files . map ( f => './' + f . path ) . find ( f => f . includes ( exercise . entry || 'app.py' ) )
77
77
if ( appPath !== undefined ) {
78
78
const content = fs . readFileSync ( appPath , "utf8" )
79
79
const count = Utils . getMatches ( / ^ ( [ ^ \/ ] ) + i n p u t \( (?: [ " ' ` ] { 1 } ( .* ) [ " ' ` ] { 1 } ) ? \) / gm, content )
You can’t perform that action at this time.
0 commit comments