File tree 3 files changed +10
-14
lines changed
Filter options
3 files changed +10
-14
lines changed
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " jspython-cli" ,
3
- "version" : " 2.1.13 " ,
3
+ "version" : " 2.1.14 " ,
4
4
"description" : " CLI for jspython. Allows you to run jspython (*.jspy) files" ,
5
5
"main" : " ./lib/public-api.js" ,
6
6
"bin" : {
Original file line number Diff line number Diff line change 1
1
import arg from 'arg' ;
2
2
import fs from 'fs' ;
3
3
import { Interpreter } from 'jspython-interpreter' ;
4
- import {
5
- AssertInfo ,
6
- initialScope ,
7
- jsPythonForNode
8
- } from './jspython-node' ;
4
+ import { AssertInfo , initialScope , jsPythonForNode } from './jspython-node' ;
9
5
import { InterpreterOptions } from './types' ;
10
6
import { trimChar } from './utils' ;
11
7
var util = require ( 'util' ) ;
@@ -23,11 +19,6 @@ process
23
19
process . exit ( 1 ) ;
24
20
} ) ;
25
21
26
- const options = getOptionsFromArguments ( process . argv ) ;
27
- const jspyContext : Record < string , any > = { ...initialScope , ...{ params : options . params } } ;
28
-
29
- const interpreter : Interpreter = jsPythonForNode ( options ) as Interpreter ;
30
-
31
22
function getOptionsFromArguments ( rawArgs : string [ ] ) : InterpreterOptions {
32
23
const args = arg (
33
24
{
@@ -82,6 +73,10 @@ function getOptionsFromArguments(rawArgs: string[]): InterpreterOptions {
82
73
}
83
74
84
75
async function main ( ) {
76
+ const options = getOptionsFromArguments ( process . argv ) ;
77
+ const interpreter : Interpreter = ( await jsPythonForNode ( options ) ) as Interpreter ;
78
+ const jspyContext : Record < string , any > = { ...initialScope , ...{ params : options . params } } ;
79
+
85
80
if ( options . version ) {
86
81
console . log ( interpreter . jsPythonInfo ( ) ) ;
87
82
console . log ( `JSPython cli v${ ( pkg || { } ) . version } \n` ) ;
Original file line number Diff line number Diff line change @@ -113,14 +113,16 @@ initialScope.params = (name: string) => {
113
113
return value === undefined ? null : value ;
114
114
} ;
115
115
116
- export function jsPythonForNode (
116
+ export async function jsPythonForNode (
117
117
options : InterpreterOptions = {
118
118
srcRoot : ''
119
119
}
120
- ) : NodeJsInterpreter {
120
+ ) : Promise < NodeJsInterpreter > {
121
121
const interpreter : NodeJsInterpreter = jsPython ( ) as NodeJsInterpreter ;
122
122
Object . assign ( context . params , options . params ) ;
123
123
124
+ await initialize ( options . srcRoot || '' ) ;
125
+
124
126
interpreter
125
127
. registerPackagesLoader ( packageLoader as PackageLoader )
126
128
. registerModuleLoader ( moduleLoader ) ;
@@ -134,7 +136,6 @@ export function jsPythonForNode(
134
136
moduleName ?: string | undefined
135
137
) {
136
138
initialScope . asserts . splice ( 0 , initialScope . asserts . length ) ;
137
- await initialize ( options . srcRoot || '' ) ;
138
139
return evaluate . call ( interpreter , script , evaluationContext , entryFunctionName , moduleName ) ;
139
140
} ;
140
141
You can’t perform that action at this time.
0 commit comments