From 8dbe3f2896ec3120e03ef4a79c91771b88157ed7 Mon Sep 17 00:00:00 2001 From: iapyang Date: Thu, 9 Jan 2020 17:29:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=94=B9=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/prepublish/prepublish.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/prepublish/prepublish.js b/lib/prepublish/prepublish.js index cd545a433..66a6fe777 100644 --- a/lib/prepublish/prepublish.js +++ b/lib/prepublish/prepublish.js @@ -5,9 +5,22 @@ if (!process.env.VERDACCIO_AUTH) { return; } +function pad2(n) {// always returns a string + return (n < 10 ? "0" : "") + n; +} + +const d = new Date(); + +const version = d.getFullYear() + + pad2(d.getMonth() + 1) + + pad2(d.getDate()) + + pad2(d.getHours()) + + pad2(d.getMinutes()) + + pad2(d.getSeconds()); + const packageJSON = require("../../package.json"); -packageJSON.version = `2.0.${new Date().getTime()}`; +packageJSON.version = `2.0.${version}`; writeFileSync(resolve(__dirname, "../../package.json"), JSON.stringify(packageJSON, null, 2));