Skip to content

Commit

Permalink
remove cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeVanti committed Nov 1, 2024
1 parent 0d1e7ee commit a8e3bc2
Showing 1 changed file with 31 additions and 40 deletions.
71 changes: 31 additions & 40 deletions src/cli/cmd-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ import { workDirOpt } from "./opt-wd";
import { ResultCodes } from "./result-codes";
import { mustBeDomainName } from "./validators";

const packageNameArg = new Argument(
"<pkg>",
"Name of the package to remove"
).argParser(mustBeDomainName);

const otherPackageNamesArg = new Argument(
"[otherPkgs...]",
"Names of additional packages to remove"
const packageNamesArg = new Argument(
"<pkg>...",
"Names of the packages to remove"
).argParser(eachValue(mustBeDomainName));

/**
Expand All @@ -43,42 +38,38 @@ export function makeRemoveCmd(
);

return new Command("remove")
.aliases(["rm", "uninstall"])
.addArgument(packageNameArg)
.addArgument(otherPackageNamesArg)
.aliases(["rm", "r", "un", "unlink", "uninstall"])
.addArgument(packageNamesArg)
.addOption(workDirOpt)
.description("remove package from manifest json")
.summary("remove dependency from project")
.description(
`Remove one or more dependencies from a project.
openupm remove com.my.package`
)
.action(
withErrorLogger(
log,
async function (packageName, otherPackageNames, options) {
const packageNames = [packageName, ...otherPackageNames];

const projectDir = options.chdir;
withErrorLogger(log, async function (packageNames, options) {
const projectDir = options.chdir;

const removeResult = await removeDependencies(
projectDir,
packageNames
).promise;
if (removeResult.isErr()) {
logError(log, removeResult.error);
return process.exit(ResultCodes.Error);
}
const removedPackages = removeResult.value;
const removeResult = await removeDependencies(projectDir, packageNames)
.promise;
if (removeResult.isErr()) {
logError(log, removeResult.error);
return process.exit(ResultCodes.Error);
}
const removedPackages = removeResult.value;

removedPackages.forEach((removedPackage) => {
log.notice(
"",
`Removed "${makePackageSpec(
removedPackage.name,
removedPackage.version
)}".`
);
});
removedPackages.forEach((removedPackage) => {
log.notice(
"",
`Removed "${makePackageSpec(
removedPackage.name,
removedPackage.version
)}".`
);
});

// print manifest notice
log.notice("", "please open Unity project to apply changes");
}
)
// print manifest notice
log.notice("", "please open Unity project to apply changes");
})
);
}

0 comments on commit a8e3bc2

Please sign in to comment.