Files
shd.build/.agents/skills/impeccable/scripts/lib/target-args.mjs
T
JB 2e868d86ff
Validate and deploy production / validate (push) Successful in 18s
Validate and deploy staging / validate (push) Successful in 18s
Validate and deploy production / deploy (push) Successful in 1m1s
Validate and deploy staging / deploy (push) Successful in 28s
feat: refine ISAC design and prepare production deployment
2026-07-26 12:25:47 -04:00

43 lines
1.1 KiB
JavaScript

class TargetArgError extends Error {
constructor(message, code) {
super(message);
this.name = 'TargetArgError';
this.code = code;
}
}
export function parseTargetPath(args = [], { strict = false } = {}) {
let targetPath = null;
for (let i = 0; i < args.length; i++) {
const arg = String(args[i]);
if (arg === '--target' || arg === '-t') {
const next = args[i + 1];
if (next && !String(next).startsWith('-')) {
targetPath = String(next);
i++;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
continue;
}
if (arg.startsWith('--target=')) {
const value = arg.slice('--target='.length);
if (value) {
targetPath = value;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
}
}
return targetPath;
}
export function parseTargetOptions(args = [], options = {}) {
const targetPath = parseTargetPath(args, options);
return targetPath ? { targetPath } : {};
}