11import arg from 'arg' ;
22import fs from 'fs' ;
33import { jsPython , Interpreter , PackageLoader } from 'jspython-interpreter' ;
4- import { httpGet , httpPost , httpDelete , httpPut } from './http' ;
54
65const 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+
79const context : any = {
810 asserts : [ ] ,
911 params : { }
1012}
1113export 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 ) ;
1614interpreter . addFunction ( 'assert' , ( condition : boolean , name ?: string , description ?: string ) => {
1715 context . asserts . push ( { condition, name, description } ) ;
1816} ) ;
2927async function run ( ) {
3028 const options = getOptionsFromArguments ( process . argv ) ;
3129 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` ) ;
3332 }
3433
3534 if ( options . output ) {
@@ -49,8 +48,8 @@ async function run() {
4948 interpreter . registerPackagesLoader ( packageLoader as PackageLoader ) ;
5049 const scripts = fs . readFileSync ( options . file , 'utf8' ) ;
5150 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 } ` )
5453 const res = await interpreter . evaluate ( scripts , undefined , undefined , options . file ) ;
5554 if ( res !== null ) {
5655 console . log ( res ) ;
0 commit comments