AIx_Smarttalk_WS/updatePackageJsonName.js

15 lines
541 B
JavaScript
Raw Normal View History

2025-01-08 13:45:40 +08:00
const fs = require('fs');
const path = require('path');
const { env } = require('process');
// 读取当前的package.json文件
const packageJsonPath = path.join(__dirname, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
console.log(env)
let res = env.npm_lifecycle_event.replace("build", "").replace(":", "");
res = res?"-" + res:"";
packageJson.name = "aix-win-ws" + res
// 将修改后的内容写回package.json文件
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));