UNPKG

tspace-sql

Version:

mysql & postgresql query builder object relational mapping

42 lines (41 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var child_process_1 = require("child_process"); exports.default = (function (_ref) { var _a, _b, _c; var path = _ref.path, type = _ref.type, cwd = _ref.cwd, fs = _ref.fs; var split = path.split('/') || path; var f = split.join('/'); try { fs.accessSync(cwd + ("/" + f), fs.F_OK, { recursive: true }); } catch (e) { fs.mkdirSync(cwd + ("/" + f), { recursive: true }); } try { var dir = cwd + "/" + f; var files = (_a = fs.readdirSync(dir)) !== null && _a !== void 0 ? _a : []; if (!(files === null || files === void 0 ? void 0 : files.length)) console.log('this folder is empty'); var cmd = type === '.js' ? 'node' : 'ts-node'; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var t = files_1[_i]; var run = (0, child_process_1.exec)(cmd + " " + dir + "/" + t); (_b = run === null || run === void 0 ? void 0 : run.stdout) === null || _b === void 0 ? void 0 : _b.on('data', function (data) { if (data) console.log(data); }); (_c = run === null || run === void 0 ? void 0 : run.stderr) === null || _c === void 0 ? void 0 : _c.on('data', function (err) { if (err) console.error(err); }); } } catch (err) { console.log(err.message); } });