wuhu-torn-helper/build.js
2022-10-19 18:05:12 +08:00

33 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 此脚本用于加入userscript meta
* 并生成日期时间与版本号
*/
let startTime = Date.now();
let fs = require('fs');
let date = new Date();
let version = process.env.npm_package_version;
let formattedDateTime = `${ date.getFullYear() }${ ('0' + (date.getMonth() + 1)).slice(-2) }${ ('0' + date.getDate()).slice(-2) }${ ('0' + date.getHours()).slice(-2) }${ ('0' + date.getMinutes()).slice(-2) }`;
let metaData = `// ==UserScript==
// @lastmodified ${ formattedDateTime }
// @name 芜湖助手
// @namespace WOOH
// @version ${ version }
// @description 托恩,起飞!
// @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/*
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @connect ljs-lyt.com
// @connect yata.yt
// @connect github.io
// @connect gitlab.com
// @connect staticfile.org
// @connect gitee.com
// ==/UserScript==
`
const data = fs.readFileSync('./bundle.min.js', 'utf8');
fs.writeFileSync('./release.min.user.js', metaData + data.replace('$$WUHU_DEV_VERSION$$', version), 'utf8');
console.log(`新版本 ${ version } 构建完成, 耗时${ Date.now() - startTime }ms`);