UNPKG

@ali-i18n-fe/dada-component

Version:
27 lines (21 loc) 807 B
const path = require("path"); const fs = require("fs"); const semver = require("semver"); const { getPackageConfig } = require("./utils/getPackageJson"); const { isDaily, isDef } = require("./utils/def"); const IncreaseVersion = { async load() { const wrotePath = path.resolve(process.cwd(), "./_wrotePath"); if (!(isDef() && isDaily()) || !!fs.existsSync(wrotePath)) { return; } const pkgJSON = getPackageConfig(); let { version } = pkgJSON; version = semver.coerce(version); pkgJSON.version = version += "-beta." + new Date().valueOf(); const pkgPath = path.resolve(process.cwd(), "./package.json"); fs.writeFileSync(pkgPath, JSON.stringify(pkgJSON, null, 2), "utf8"); fs.writeFileSync(wrotePath, "", "utf8"); }, }; module.exports = IncreaseVersion;