diff --git a/packages/f2elint/package.json b/packages/f2elint/package.json index c7f1afa..459e37a 100644 --- a/packages/f2elint/package.json +++ b/packages/f2elint/package.json @@ -1,6 +1,6 @@ { "name": "f2elint", - "version": "4.0.0-beta.3", + "version": "4.0.0-beta.4", "description": "Linter for Alibaba F2E Guidelines", "keywords": [ "f2elint", @@ -66,16 +66,25 @@ "dependencies": { "@clack/prompts": "^0.7.0", "chalk": "^5.3.0", + "command-exists": "^1.2.9", "commander": "^12.0.0", "init-roll": "^1.0.10" }, "devDependencies": { "@commitlint/cli": "^16.3.0", "@mdx-js/react": "^3.0.0", + "@types/command-exists": "^1.2.3", + "@types/cross-spawn": "^6.0.6", + "@types/ejs": "^3.1.5", + "@types/eslint": "^8.56.2", + "@types/fs-extra": "^9.0.13", + "@types/glob": "^7.2.0", + "@types/lodash": "^4.14.202", + "@types/node": "^20.0.0", + "@types/react": "^18.2.52", + "@types/react-dom": "^18.2.18", + "@types/text-table": "^0.2.5", "commitlint-config-ali": "workspace:^", - "markdownlint": "0.x", - "markdownlint-config-ali": "workspace:^", - "markdownlint-rule-helpers": "^0.13.0", "eslint": "^8.56.0", "eslint-config-ali": "workspace:^", "eslint-config-egg": "^10.0.0", @@ -87,24 +96,16 @@ "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-vue": "^7.20.0", - "@types/command-exists": "^1.2.3", - "@types/cross-spawn": "^6.0.6", - "@types/ejs": "^3.1.5", - "@types/eslint": "^8.56.2", - "@types/fs-extra": "^9.0.13", - "@types/glob": "^7.2.0", - "@types/lodash": "^4.14.202", - "@types/node": "^20.0.0", - "@types/react": "^18.2.52", - "@types/react-dom": "^18.2.18", - "@types/text-table": "^0.2.5", "gh-pages": "^5.0.0", + "markdownlint": "0.x", + "markdownlint-config-ali": "workspace:^", + "markdownlint-rule-helpers": "^0.13.0", "react": "^18.2.0", "react-doc-ui": "^2.2.1", "react-dom": "^18.2.0", + "rive": "^2.0.22", "stylelint": "^16.2.1", "stylelint-config-ali": "workspace:^", - "rive": "^2.0.22", "typescript": "^5.3.3" }, "rive": { diff --git a/packages/f2elint/src/private/install.ts b/packages/f2elint/src/private/install.ts index cae1c3e..2f062a1 100644 --- a/packages/f2elint/src/private/install.ts +++ b/packages/f2elint/src/private/install.ts @@ -1,8 +1,18 @@ import { spawn } from 'child_process'; +import commandExists from 'command-exists'; -export function install(projectPath: string) { - return new Promise((res, rej) => { - const child = spawn(`${process.env.npm_command} update -f`, { +export async function install(projectPath: string) { + let npm_command = 'npm'; + if (await commandExists('tnpm')) { + // tnpm of Alibaba and Ant Group + npm_command = 'tnpm'; + } else if (process.env.npm_command) { + // pnpm, yarn support npm_command environment variable + npm_command = process.env.npm_command; + } + + await new Promise((res, rej) => { + const child = spawn(`${npm_command} update -f`, { cwd: projectPath, shell: true, });