UNPKG

@launchql/migrate

Version:
51 lines (50 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getModulePath = exports.getWorkspacePath = exports.launchqlPath = exports.sqitchPath = void 0; const utils_1 = require("./utils"); const PROJECT_FILES = { SQITCH: 'sqitch.conf', LAUNCHQL: 'launchql.json', }; /** * Finds the Sqitch project path. * @param cwd - Current working directory. * @returns A promise that resolves to the directory path containing `sqitch.conf`. */ const sqitchPath = (cwd = process.cwd()) => { return (0, utils_1.walkUp)(cwd, PROJECT_FILES.SQITCH); }; exports.sqitchPath = sqitchPath; /** * Finds the LaunchQL project path. * @param cwd - Current working directory. * @returns A promise that resolves to the directory path containing `launchql.json`. */ const launchqlPath = (cwd = process.cwd()) => { return (0, utils_1.walkUp)(cwd, PROJECT_FILES.LAUNCHQL); }; exports.launchqlPath = launchqlPath; const getWorkspacePath = (cwd) => { let workspacePath; try { workspacePath = (0, exports.launchqlPath)(cwd); } catch (err) { console.error('Error: You must be in a LaunchQL workspace. You can initialize one with the `--workspace` option.'); process.exit(1); } return workspacePath; }; exports.getWorkspacePath = getWorkspacePath; const getModulePath = (cwd) => { let pkgPath; try { pkgPath = (0, exports.sqitchPath)(cwd); } catch (err) { console.error('Error: You must be in a LaunchQL module. You can initialize one with the `init` command.'); process.exit(1); } return pkgPath; }; exports.getModulePath = getModulePath;