Skip to content

Commit 5a257f4

Browse files
committed
fix: perfect version for cli install
1 parent 5af4b70 commit 5a257f4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

esbuild.config.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ const publishFields = [
1010
"description",
1111
"author",
1212
"license",
13-
"publishConfig"
13+
"publishConfig",
14+
"type",
15+
"dependencies"
1416
];
15-
fs.unlink(path.resolve(rootPath, 'pl-cli'),(err)=>{
16-
if(err)return;
17+
fs.unlink(path.resolve(rootPath, 'pl-cli'), (err) => {
18+
if (err) return;
1719
console.log("清理pl-cli成功")
1820
})
1921
await esbuild.build({
@@ -36,8 +38,15 @@ await esbuild.build({
3638
// 构建完成后执行的操作
3739
// 复制文件
3840
fs.copyFileSync(path.resolve(rootPath, 'Readme.md'), path.resolve(rootPath, 'pl-cli/Readme.md'));
39-
const newPackageJson = publishFields?.reduce((acc,key)=>Object.assign(acc,{[key]:packageJson[key]}),{});
40-
fs.writeFileSync(path.resolve(rootPath, 'pl-cli/package.json'),JSON.stringify(newPackageJson));
41+
fs.copyFileSync(path.resolve(rootPath, 'LICENSE'), path.resolve(rootPath, 'pl-cli/LICENSE'));
42+
const newPackageJson = publishFields?.reduce((acc, key) => Object.assign(acc, {[key]: packageJson[key]}), {
43+
bin: {
44+
"lk": ".bin/lk.js",
45+
"lf": ".bin/lf.js",
46+
"lc": ".bin/lc.js"
47+
}
48+
});
49+
fs.writeFileSync(path.resolve(rootPath, 'pl-cli/package.json'), JSON.stringify(newPackageJson));
4150
console.log("[LP]脚本打包完成,查看目录[pl-cli].")
4251
}).catch((e) => {
4352
console.error("[LP]脚本打包失败", e);

0 commit comments

Comments
 (0)