@launchql/core
Version:
LaunchQL Package and Migration Tools
51 lines (50 loc) • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getModulePath = exports.getWorkspacePath = exports.launchqlPath = exports.modulePath = void 0;
const utils_1 = require("./utils");
const PROJECT_FILES = {
PLAN: 'launchql.plan',
LAUNCHQL: 'launchql.json',
};
/**
* Finds the module path by looking for launchql.plan.
* @param cwd - Current working directory.
* @returns A promise that resolves to the directory path containing `launchql.plan`.
*/
const modulePath = (cwd = process.cwd()) => {
return (0, utils_1.walkUp)(cwd, PROJECT_FILES.PLAN);
};
exports.modulePath = modulePath;
/**
* 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.modulePath)(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;