UNPKG

sequelize-typescript-migration-rafaeltab

Version:
37 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); function removeCurrentRevisionMigrations(revision, migrationsPath, options) { return new Promise((resolve, reject) => { if (options.keepFiles) { resolve(false); } try { const files = fs.readdirSync(migrationsPath); if (files.length === 0) { resolve(false); } let i = 0; files.forEach(file => { i += 1; if (file.split("-")[0] === revision.toString()) { fs.unlinkSync(`${migrationsPath}/${file}`); if (options.verbose) { console.log(`Successfully deleted ${file}`); resolve(true); } } if (i === files.length) { resolve(false); } }); } catch (err) { if (options.debug) console.error(`에러발생: ${err}`); resolve(false); } }); } exports.default = removeCurrentRevisionMigrations; //# sourceMappingURL=removeCurrentRevisionMigrations.js.map