From bb85e27f337d6fe8705c398203506d84c7bcfee4 Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Tue, 27 Aug 2024 18:48:33 +0800 Subject: [PATCH] build: fix version text --- rollup.config.js | 2 +- scripts/build-html.cjs | 2 +- scripts/utils.cjs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 257dbb1..8e136d0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -31,7 +31,7 @@ export default [ include: 'src/core/index.ts', // (!) [plugin replace] @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`. preventAssignment: true, - values: { _version_: version() }, + values: { _version_: version().text }, }), ...[dev ? [] : [terser(terserOptions)]], ], diff --git a/scripts/build-html.cjs b/scripts/build-html.cjs index d1e3c02..b787d6e 100644 --- a/scripts/build-html.cjs +++ b/scripts/build-html.cjs @@ -37,7 +37,7 @@ const setVersion = () => { ?.setAttribute('href', github) .removeAttribute('id'); html.getElementById('version') - ?.set_content(v.text) + ?.set_content(v.textShort) .setAttribute('href', github + (v.dirty ? '' : `/tree/${v.commit}`)) .removeAttribute('id'); }; diff --git a/scripts/utils.cjs b/scripts/utils.cjs index 4264021..12c4f88 100644 --- a/scripts/utils.cjs +++ b/scripts/utils.cjs @@ -12,8 +12,10 @@ const version = () => { commit: commitHash(), dirty: isDirty(), text: '', + textShort: '', }; - r.text = `${r.branch}@${r.commit.slice(0, 8)}${r.dirty ? '(dirty)' : ''}`; + r.text = `${r.branch}@${r.commit}${r.dirty ? '(dirty)' : ''}`; + r.textShort = `${r.branch}@${r.commit.slice(0, 8)}${r.dirty ? '*' : ''}`; return r; };