UNPKG

graphile-migrate

Version:

Opinionated SQL-powered migration tool for PostgreSQL

34 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const migration_1 = require("../migration"); const settings_1 = require("../settings"); const _common_1 = require("./_common"); async function compile(settings, content, shadow = false) { const parsedSettings = await settings_1.parseSettings(settings, shadow); return migration_1.compilePlaceholders(parsedSettings, content, shadow); } exports.compile = compile; exports.compileCommand = { command: "compile [file]", aliases: [], describe: `\ Compiles a SQL file, inserting all the placeholders and returning the result to STDOUT`, builder: { shadow: { type: "boolean", default: false, description: "Apply shadow DB placeholders (for development).", }, }, handler: async (argv) => { const settings = await _common_1.getSettings({ configFile: argv.config }); const content = typeof argv.file === "string" ? await fs_1.promises.readFile(argv.file, "utf8") : await _common_1.readStdin(); const compiled = await compile(settings, content, argv.shadow); // eslint-disable-next-line no-console console.log(compiled); }, }; //# sourceMappingURL=compile.js.map