1
1
import arg from 'arg' ;
2
2
import fs from 'fs' ;
3
3
import { jsPython , Interpreter , PackageLoader } from 'jspython-interpreter' ;
4
- import { httpGet , httpPost , httpDelete , httpPut } from './http' ;
5
4
6
5
const pkg = require ( '../package.json' ) ;
6
+ const appConfig = require ( `${ process . cwd ( ) . split ( '\\' ) . join ( '/' ) } /jspy.config.js` )
7
+ || require ( `${ process . cwd ( ) . split ( '\\' ) . join ( '/' ) } /jspy.config.json` )
8
+
7
9
const context : any = {
8
10
asserts : [ ] ,
9
11
params : { }
10
12
}
11
13
export const interpreter : Interpreter = jsPython ( ) as Interpreter ;
12
- interpreter . addFunction ( 'httpGet' , httpGet ) ;
13
- interpreter . addFunction ( 'httpPost' , httpPost ) ;
14
- interpreter . addFunction ( 'httpDelete' , httpDelete ) ;
15
- interpreter . addFunction ( 'httpPut' , httpPut ) ;
16
14
interpreter . addFunction ( 'assert' , ( condition : boolean , name ?: string , description ?: string ) => {
17
15
context . asserts . push ( { condition, name, description } ) ;
18
16
} ) ;
29
27
async function run ( ) {
30
28
const options = getOptionsFromArguments ( process . argv ) ;
31
29
if ( options . version ) {
32
- console . log ( `Version:\n${ pkg . version } \n` ) ;
30
+ console . log ( interpreter . jsPythonInfo ( ) ) ;
31
+ console . log ( `JSPython cli v${ ( pkg || { } ) . version } \n` ) ;
33
32
}
34
33
35
34
if ( options . output ) {
@@ -49,8 +48,8 @@ async function run() {
49
48
interpreter . registerPackagesLoader ( packageLoader as PackageLoader ) ;
50
49
const scripts = fs . readFileSync ( options . file , 'utf8' ) ;
51
50
context . asserts . length = 0 ;
52
- console . log ( "JSPython (c) FalconSoft Ltd" )
53
- console . log ( `${ options . file } ` )
51
+ console . log ( interpreter . jsPythonInfo ( ) )
52
+ console . log ( `> ${ options . file } ` )
54
53
const res = await interpreter . evaluate ( scripts , undefined , undefined , options . file ) ;
55
54
if ( res !== null ) {
56
55
console . log ( res ) ;
0 commit comments