import fs from 'node:fs' import path, { dirname } from 'node:path' import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = dirname(__filename) const packagePath = path.resolve(__dirname, 'package.json') const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8')) // 读取命令行参数(默认使用 'DT300W') // eslint-disable-next-line node/prefer-global/process const deviceType = process.argv[2] || 'DT300W' packageJson.device = deviceType fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2)) console.log(`device updated to: ${deviceType}`)