ddl-manager
Version:
store postgres procedures and triggers in files
39 lines • 1.21 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareError = exports.getSubPath = exports.isSqlFile = exports.formatPath = void 0;
const fs_1 = __importDefault(require("fs"));
function formatPath(inputFilePath) {
const filePaths = inputFilePath.split(/[/\\]/);
const outputFilePath = filePaths.join("/");
return outputFilePath;
}
exports.formatPath = formatPath;
function isSqlFile(filePath) {
if (!/\.sql$/.test(filePath)) {
return false;
}
let stat;
try {
stat = fs_1.default.lstatSync(filePath);
}
catch (err) {
return false;
}
return stat.isFile();
}
exports.isSqlFile = isSqlFile;
function getSubPath(rootFolderPath, fullFilePath) {
const subPath = fullFilePath.slice(rootFolderPath.length + 1);
return subPath;
}
exports.getSubPath = getSubPath;
function prepareError(err, subPath) {
const outError = new Error(err.message);
outError.subPath = subPath;
return outError;
}
exports.prepareError = prepareError;
//# sourceMappingURL=utils.js.map