Skip to content

Commit 6b4c24b

Browse files
committed
Updated package loader
1 parent 6d84069 commit 6b4c24b

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jspython-dev/jspython-cli",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "CLI for jspython. Allows you to run jspython (*.jspy) files",
55
"main": "src/index.ts",
66
"bin": {
@@ -28,7 +28,7 @@
2828
},
2929
"homepage": "https://github.com/jspython-dev/jspython-cli#readme",
3030
"dependencies": {
31-
"@jspython-dev/jspython": "0.0.1",
31+
"@jspython-dev/jspython": "^0.0.3",
3232
"arg": "^4.1.1"
3333
},
3434
"devDependencies": {

src/index.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import arg from 'arg';
22
import fs from 'fs';
3-
import { jsPython, PackageToImport, Interpreter, PackageLoader } from '@jspython-dev/jspython';
3+
import { jsPython, Interpreter, PackageLoader } from '@jspython-dev/jspython';
44

55
const pkg = require('../package.json');
66

@@ -40,22 +40,6 @@ function getOptionsFromArguments(rawArgs: string[]) {
4040
}
4141

4242
/**@type {PackageLoader} */
43-
function packageLoader(packages: PackageToImport[]): object {
44-
const libraries: any = {};
45-
packages.forEach(({ name, as, properties }: PackageToImport) => {
46-
const lib = require(name);
47-
if (properties?.length) {
48-
properties.forEach((prop) => {
49-
libraries[prop.as || prop.name] = lib[prop.name];
50-
})
51-
} else if (as) {
52-
libraries[as] = lib;
53-
} else {
54-
libraries[name] = lib;
55-
}
56-
if (as) {
57-
libraries[as] = lib;
58-
}
59-
});
60-
return libraries;
43+
function packageLoader(packageName: string): any {
44+
return require(packageName);
6145
}

0 commit comments

Comments
 (0)