Replies: 1 comment
-
|
To add a global installation option to your
// HomePage/InstallPackage.tsx
import React from 'react';
interface InstallPackageProps {
type: 'init' | 'add' | 'global';
packageName: string;
}
const InstallPackage: React.FC<InstallPackageProps> = ({ type, packageName }) => {
let command = '';
switch (type) {
case 'init':
command = `pnpm init ${packageName}`;
break;
case 'add':
command = `pnpm add ${packageName}`;
break;
case 'global':
command = `pnpm add -g ${packageName}`;
break;
default:
command = '';
}
return (
<div>
<code>{command}</code>
</div>
);
};
export default InstallPackage;
// Usage example
import React from 'react';
import InstallPackage from './HomePage/InstallPackage';
const MyComponent: React.FC = () => {
return (
<div>
<h1>Install My CLI</h1>
<InstallPackage type="global" packageName="my-cli-package" />
</div>
);
};
export default MyComponent;This modification introduces a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm developing a CLI, and would like for people to install it with
pnpm add -g(and equivalents for other package managers). However, theHomePage.InstallPackagecomponent only allows two types:initandadd.Beta Was this translation helpful? Give feedback.
All reactions