Skip to content

Commit fd73398

Browse files
committed
upgraded jspython and fixed import
1 parent 2af86ac commit fd73398

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspython-cli",
3-
"version": "0.0.7",
3+
"version": "2.0.4",
44
"description": "CLI for jspython. Allows you to run jspython (*.jspy) files",
55
"main": "src/index.ts",
66
"bin": {
@@ -9,7 +9,8 @@
99
"scripts": {
1010
"test": "echo \"Error: no test specified\" && exit 1",
1111
"dev": "npx rollup -c rollup.config.dev.js",
12-
"build": "npx rollup -c rollup.config.js"
12+
"build": "npx rollup -c rollup.config.js",
13+
"build:publish": "npm run build && npm publish"
1314
},
1415
"repository": {
1516
"type": "git",
@@ -29,7 +30,7 @@
2930
"homepage": "https://github.com/jspython-dev/jspython-cli#readme",
3031
"dependencies": {
3132
"arg": "^4.1.2",
32-
"jspython-interpreter": "~0.1.3"
33+
"jspython-interpreter": "~2.0.7"
3334
},
3435
"devDependencies": {
3536
"rollup": "^1.27.13",

src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function getOptionsFromArguments(rawArgs: string[]) {
6767
permissive: true
6868
});
6969

70-
const params = args._.reduce((obj: {[key: string]: any}, a: string) => {
70+
const params = args._.reduce((obj: { [key: string]: any }, a: string) => {
7171
const kv = a.replace('--', '');
7272
let [key, val]: any = kv.split('=');
7373
if (kv === key) {
@@ -83,12 +83,22 @@ function getOptionsFromArguments(rawArgs: string[]) {
8383
output: args['--output']
8484
};
8585

86-
context.params = {...res, ...params};
86+
context.params = { ...res, ...params };
8787

8888
return res;
8989
}
9090

9191
/**@type {PackageLoader} */
9292
function packageLoader(packageName: string): any {
93-
return require(packageName);
93+
if (['fs', 'path', 'readline', 'timers', 'child_process', 'util', 'zlib', 'stream', 'net', 'https', 'http', 'events', 'os', 'buffer']
94+
.includes(packageName)) {
95+
return require(packageName)
96+
}
97+
98+
try {
99+
return require(`${process.cwd().split('\\').join('/')}/node_modules/${packageName}`);
100+
}
101+
catch (err) {
102+
console.log('Import Error: ', err);
103+
}
94104
}

0 commit comments

Comments
 (0)