Yargs command handler for the command.
({projectRoot}: Arguments<BuildAndLinkOptions>)
| 33 | |
| 34 | /** Yargs command handler for the command. */ |
| 35 | async function handler({projectRoot}: Arguments<BuildAndLinkOptions>) { |
| 36 | try { |
| 37 | if (!lstatSync(projectRoot).isDirectory()) { |
| 38 | Log.error(` ✘ The 'projectRoot' must be a directory: ${projectRoot}`); |
| 39 | process.exit(1); |
| 40 | } |
| 41 | } catch { |
| 42 | Log.error(` ✘ Could not find the 'projectRoot' provided: ${projectRoot}`); |
| 43 | process.exit(1); |
| 44 | } |
| 45 | |
| 46 | const config = await getConfig(); |
| 47 | assertValidReleaseConfig(config); |
| 48 | |
| 49 | const builtPackages = await BuildWorker.invokeBuild(); |
| 50 | |
| 51 | if (builtPackages === null) { |
| 52 | Log.error(` ✘ Could not build release output. Please check output above.`); |
| 53 | process.exit(1); |
| 54 | } |
| 55 | Log.info(green(` ✓ Built release output.`)); |
| 56 | |
| 57 | for (const {outputPath, name} of builtPackages) { |
| 58 | await ChildProcess.spawn('pnpm', ['--dir', outputPath, 'link', '--global']); |
| 59 | await ChildProcess.spawn('pnpm', ['--dir', projectRoot, 'link', '--global', name]); |
| 60 | } |
| 61 | |
| 62 | Log.info(green(` ✓ Linked release packages in provided project.`)); |
| 63 | } |
| 64 | |
| 65 | /** CLI command module. */ |
| 66 | export const BuildAndLinkCommandModule: CommandModule<{}, BuildAndLinkOptions> = { |
nothing calls this directly
no test coverage detected