impeccable project-wide (#27)

Reviewed-on: #27
Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit was merged in pull request #27.
This commit is contained in:
2026-07-16 22:12:56 +00:00
committed by archvillainette
parent 60bcd589c0
commit 1b99c93193
106 changed files with 51536 additions and 0 deletions
@@ -0,0 +1,30 @@
import path from 'node:path';
import { resolveProjectRoot } from './context.mjs';
import { parseTargetPath } from './lib/target-args.mjs';
export function resolveLiveTarget(cwd = process.cwd(), args = []) {
const originalCwd = path.resolve(cwd);
let targetPath = null;
try {
targetPath = parseTargetPath(args, { strict: true });
} catch (err) {
if (err?.name === 'TargetArgError') {
process.stderr.write(`${err.message}\n`);
process.exit(1);
}
throw err;
}
const absoluteTargetPath = targetPath
? path.isAbsolute(targetPath) ? targetPath : path.resolve(originalCwd, targetPath)
: null;
const projectRoot = targetPath
? resolveProjectRoot(originalCwd, { targetPath: absoluteTargetPath })
: originalCwd;
return {
originalCwd,
projectRoot,
targetPath,
absoluteTargetPath,
targetOptions: absoluteTargetPath ? { targetPath: absoluteTargetPath } : {},
};
}