UNPKG

@launchql/migrate

Version:
44 lines (43 loc) 1.29 kB
import { walkUp } from './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`. */ export const sqitchPath = (cwd = process.cwd()) => { return walkUp(cwd, PROJECT_FILES.SQITCH); }; /** * Finds the LaunchQL project path. * @param cwd - Current working directory. * @returns A promise that resolves to the directory path containing `launchql.json`. */ export const launchqlPath = (cwd = process.cwd()) => { return walkUp(cwd, PROJECT_FILES.LAUNCHQL); }; export const getWorkspacePath = (cwd) => { let workspacePath; try { workspacePath = 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; }; export const getModulePath = (cwd) => { let pkgPath; try { pkgPath = 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; };