Skip to content

Commit acd5bc9

Browse files
committed
chore: warning for missing @rc-component/np
1 parent e0f6ee7 commit acd5bc9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rc-component/father-plugin",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "The father plugin for all react-component projects",
55
"keywords": [],
66
"repository": "https://github.com/react-component/father-plugin.git",
@@ -34,6 +34,9 @@
3434
"prettier --parser=typescript --write"
3535
]
3636
},
37+
"dependencies": {
38+
"fs-extra": "^11.3.0"
39+
},
3740
"devDependencies": {
3841
"@commitlint/cli": "^17.1.2",
3942
"@commitlint/config-conventional": "^17.1.0",

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { exec, execSync } from 'child_process';
22
import type { IApi } from 'father';
3+
import fs from 'fs-extra';
4+
import path from 'path';
5+
6+
const cwd = process.cwd();
37

48
// 检查是否已安装 npm 包
59
function checkNpmPackageInstalled(packageName: string) {
@@ -17,6 +21,13 @@ export default (api: IApi) => {
1721
return;
1822
}
1923

24+
// Break if current project not install `@rc-component/np`
25+
const packageJson = await fs.readJson(path.join(cwd, 'package.json'));
26+
if (!packageJson.devDependencies['@rc-component/np']) {
27+
console.log('Please install `@rc-component/np` instead of `np`.');
28+
process.exit(1);
29+
}
30+
2031
const inputFolder =
2132
api?.config?.esm?.input || api?.config?.esm?.input || 'src/';
2233

@@ -26,7 +37,7 @@ export default (api: IApi) => {
2637
// Requires compatibility with Windows environment
2738
`npx eslint ${inputFolder} --ext .tsx,.ts --rule "@typescript-eslint/consistent-type-exports: error"`,
2839
{
29-
cwd: process.cwd(),
40+
cwd,
3041
env: process.env,
3142
stdio: [process.stdin, process.stdout, process.stderr],
3243
encoding: 'utf-8',

0 commit comments

Comments
 (0)