Skip to content

Commit cca6784

Browse files
committed
chore: update
1 parent 6dc8463 commit cca6784

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/index.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { createWriteStream, existsSync, promises as fsp } from 'node:fs'
33
import http from 'node:http'
44
import https from 'node:https'
55
import path from 'node:path'
6-
import process from 'node:process'
76
import { fileURLToPath } from 'node:url'
87
import * as tar from 'tar'
98
/**
@@ -28,9 +27,17 @@ export async function fetchAndExtractPackage(options: { name: string, dist?: str
2827
// 为了兼容低版本 npm,需要 package.json, 这里把外层的 package.json copy 一份到当前位置
2928
// 判断当前位置是否有 package.json, 如果无从外层 copy 进来
3029
const commonIntellisensePackageJsonPath = path.join(url, '..', 'package.json')
31-
const distPackageJsonPath = process.env.VITEST ? path.join(tempDir, '../../', 'package.json') : path.join(tempDir, 'package.json')
32-
if (!existsSync(distPackageJsonPath)) {
33-
await fsp.copyFile(commonIntellisensePackageJsonPath, distPackageJsonPath)
30+
const distPackageJsonPath = path.join(commonIntellisensePackageJsonPath, '..', 'package.json')
31+
if (!existsSync(commonIntellisensePackageJsonPath)) {
32+
if (!existsSync(distPackageJsonPath)) {
33+
await fsp.writeFile(commonIntellisensePackageJsonPath, JSON.stringify({
34+
name: 'temp',
35+
version: '1.0.0',
36+
}), 'utf-8')
37+
}
38+
else {
39+
await fsp.copyFile(commonIntellisensePackageJsonPath, distPackageJsonPath)
40+
}
3441
}
3542
// Create temporary directory
3643
await fsp.mkdir(tempDir, { recursive: true })

0 commit comments

Comments
 (0)