()
| 28 | specs = Option.Rest(); |
| 29 | |
| 30 | async execute() { |
| 31 | const specs: Array<string | Descriptor> = this.specs; |
| 32 | |
| 33 | const installLocations: Array<string> = []; |
| 34 | |
| 35 | if (specs.length === 0) { |
| 36 | const lookup = await specUtils.loadSpec(this.context.cwd); |
| 37 | switch (lookup.type) { |
| 38 | case `NoProject`: |
| 39 | throw new UsageError(`Couldn't find a project in the local directory - please specify the package manager to pack, or run this command from a valid project`); |
| 40 | |
| 41 | case `NoSpec`: |
| 42 | throw new UsageError(`The local project doesn't feature a 'packageManager' field - please specify the package manager to pack, or update the manifest to reference it`); |
| 43 | |
| 44 | default: { |
| 45 | specs.push(lookup.getSpec()); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | for (const request of specs) { |
| 51 | const spec = typeof request === `string` |
| 52 | ? specUtils.parseSpec(request, `CLI arguments`, {enforceExactVersion: false}) |
| 53 | : request; |
| 54 | |
| 55 | const resolved = await this.context.engine.resolveDescriptor(spec, {allowTags: true}); |
| 56 | if (resolved === null) |
| 57 | throw new UsageError(`Failed to successfully resolve '${spec.range}' to a valid ${spec.name} release`); |
| 58 | |
| 59 | if (!this.json) { |
| 60 | if (this.activate) { |
| 61 | this.context.stdout.write(`Preparing ${spec.name}@${spec.range} for immediate activation...\n`); |
| 62 | } else { |
| 63 | this.context.stdout.write(`Preparing ${spec.name}@${spec.range}...\n`); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | const installSpec = await this.context.engine.ensurePackageManager(resolved); |
| 68 | installLocations.push(installSpec.location); |
| 69 | |
| 70 | if (this.activate) { |
| 71 | await this.context.engine.activatePackageManager(resolved); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if (this.output) { |
| 76 | const outputName = typeof this.output === `string` |
| 77 | ? this.output |
| 78 | : `corepack.tgz`; |
| 79 | |
| 80 | const baseInstallFolder = folderUtils.getInstallFolder(); |
| 81 | const outputPath = path.resolve(this.context.cwd, outputName); |
| 82 | |
| 83 | if (!this.json) |
| 84 | this.context.stdout.write(`Packing the selected tools in ${path.basename(outputPath)}...\n`); |
| 85 | |
| 86 | const {create: tarC} = await import(`tar/create`); |
| 87 | // Recreate the folder in case it was deleted somewhere else: |
nothing calls this directly
no test coverage detected