tspace-mysql
Version:
Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.
57 lines • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tool = void 0;
class Tool {
static import(name) {
try {
return require(name);
}
catch (err) {
throw new Error(`The package '${name}' does not exist. Please try installing the package using : npm install ${name} --save`);
}
}
static get fs() {
try {
const fs = require('fs');
return {
existsSync: (v) => fs.existsSync(v),
writeFileSync: (path, data, options = {}) => fs.writeFileSync(path, data, options),
readdirSync: (path, options = { withFileTypes: false }) => fs.readdirSync(path, options),
readFileSync: (path, encoding) => fs.readFileSync(path, encoding)
};
}
catch (err) {
throw new Error(`The package 'fs' is not supported. Please ensure you are running in a Node.js environment.`);
}
}
static get path() {
try {
const path = require('path');
return {
join: (...paths) => path.join(...paths),
resolve: (...paths) => {
return paths == null || !paths.length
? path.resolve()
: path.resolve(...paths);
}
};
}
catch (err) {
throw new Error(`The package 'path' is not supported. Please ensure you are running in a Node.js environment.`);
}
}
static get dotenv() {
try {
const dotenv = require('dotenv');
return {
config: (options = {}) => dotenv.config(options),
};
}
catch (err) {
throw new Error(`The package 'dotenv' is either not supported or not found. Please ensure you are running in a Node.js environment or try installing it with : npm install dotenv --save`);
}
}
}
exports.Tool = Tool;
exports.default = Tool;
//# sourceMappingURL=index.js.map