UNPKG

zyk-cli

Version:

生成 React 或 Vue初始代码,生成 webpack 配置,以及配置 webpack 优化项

39 lines (32 loc) 838 B
import path from "node:path"; import fs from "fs-extra"; import Options from "../utils/options"; const opts = Options.getInstance(); class Package { private static instance: Package; private path: string; private currentPackage: any; constructor() { this.path = path.join(opts.get("base"), "/package.json"); } static getInstance() { if (!Package.instance) { Package.instance = new Package(); } return Package.instance; } initPath() { this.path = path.join(opts.get("base"), "/package.json"); this.currentPackage = fs.readJSONSync(this.path, "utf-8"); } get() { return this.currentPackage; } setWhole(pkg: any) { this.currentPackage = pkg; } set(k: string, v: any) { this.currentPackage[k] = v; } } export default Package;