Skip to content

Commit

Permalink
fix: manifest commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tomicvladan committed Nov 28, 2023
1 parent a227991 commit d77c711
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/command/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { GroupCommand } from 'furious-commander'
import { Add } from './add'
import { Create } from './create'
import { Download } from './download'
import { List } from './list'
import { Merge } from './merge'
import { Remove } from './remove'
import { Sync } from './sync'

export class Manifest implements GroupCommand {
public readonly name = 'manifest'
public readonly description = 'Operate on manifests'

public subCommandClasses = [Download, List]
public subCommandClasses = [Add, Create, Download, List, Merge, Remove, Sync]
}
18 changes: 18 additions & 0 deletions src/command/manifest/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,27 @@ export class Remove extends ManifestCommand implements LeafCommand {
const forks = this.findAllValueForks(node)
for (const fork of forks) {
if (fork.path === address.path || fork.path.startsWith(address.path + '/')) {
const childPaths = this.findAllValueForks(fork.node).map(({ path }) => fork.path + path)

if (childPaths.length > 0) {
const confirmed = await this.promptAdditionalFileDelete(fork.path, childPaths)

if (!confirmed) {
continue
}
}

node.removePath(this.encodePath(fork.path))
}
}
await this.saveAndPrintNode(node, this.stamp)
}

protected promptAdditionalFileDelete(mainPath: string, paths: string[]): Promise<boolean> {
return this.console.confirmAndDelete(
`Deleting the ${mainPath} will result in deletion of the additional resources: \n\t${paths.join(
'\n\t',
)}\nContinue?`,
)
}
}

0 comments on commit d77c711

Please sign in to comment.