mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 23:02:40 +01:00
feat: support for inbuilt libraries during scripting
This commit is contained in:
parent
b800055df4
commit
905f459ed0
@ -16,7 +16,10 @@
|
|||||||
"@usebruno/js": "0.1.0",
|
"@usebruno/js": "0.1.0",
|
||||||
"@usebruno/lang": "0.1.0",
|
"@usebruno/lang": "0.1.0",
|
||||||
"@usebruno/schema": "0.1.0",
|
"@usebruno/schema": "0.1.0",
|
||||||
|
"ajv": "^8.12.0",
|
||||||
|
"atob": "^2.1.2",
|
||||||
"axios": "^0.26.0",
|
"axios": "^0.26.0",
|
||||||
|
"btoa": "^1.2.1",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"electron-is-dev": "^2.0.0",
|
"electron-is-dev": "^2.0.0",
|
||||||
"electron-store": "^8.1.0",
|
"electron-store": "^8.1.0",
|
||||||
@ -25,8 +28,10 @@
|
|||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"is-valid-path": "^0.1.1",
|
"is-valid-path": "^0.1.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"moment": "^2.29.4",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"nanoid": "3.3.4",
|
"nanoid": "3.3.4",
|
||||||
|
"uuid": "^9.0.0",
|
||||||
"vm2": "^3.9.13",
|
"vm2": "^3.9.13",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
},
|
},
|
||||||
|
@ -1,8 +1,36 @@
|
|||||||
|
|
||||||
|
// Inbuilt Library Support
|
||||||
|
const atob = require('atob');
|
||||||
|
const btoa = require('btoa');
|
||||||
|
const _ = require('lodash');
|
||||||
|
const moment = require('moment');
|
||||||
|
const uuid = require('uuid');
|
||||||
|
const nanoid = require('nanoid');
|
||||||
|
|
||||||
class Bru {
|
class Bru {
|
||||||
constructor(environment) {
|
constructor(environment) {
|
||||||
this._environment = environment;
|
this._environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require(module) {
|
||||||
|
switch(module) {
|
||||||
|
case 'atob':
|
||||||
|
return atob;
|
||||||
|
case 'btoa':
|
||||||
|
return btoa;
|
||||||
|
case 'lodash':
|
||||||
|
return _;
|
||||||
|
case 'moment':
|
||||||
|
return moment;
|
||||||
|
case 'uuid':
|
||||||
|
return uuid;
|
||||||
|
case 'nanoid':
|
||||||
|
return nanoid;
|
||||||
|
default:
|
||||||
|
throw new Error(`Module ${module} is not supported`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getEnvVar(key) {
|
getEnvVar(key) {
|
||||||
return this._environment[key];
|
return this._environment[key];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user