36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
#! /usr/bin/env node
|
|
const fs = require('fs');
|
|
const dayjs = require('dayjs');
|
|
const timezone = require('dayjs/plugin/timezone');
|
|
const utc = require('dayjs/plugin/utc');
|
|
var localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
|
|
dayjs.extend(utc);
|
|
dayjs.extend(timezone);
|
|
dayjs.extend(localizedFormat);
|
|
|
|
const write = (content, path) => {
|
|
const writePath = path || `${process.cwd()}/src/build.ts`;
|
|
try {
|
|
fs.writeFileSync(
|
|
writePath,
|
|
'// Build information, automatically generated by `the_build_script` :zwinkern:\n' + 'const build = ' + JSON.stringify(content, null, 4).replace(/\"([^(\")"]+)\":/g, '$1:') + ';\n\nexport default build;',
|
|
);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
};
|
|
const package = require(`${process.cwd()}/package.json`);
|
|
(() => {
|
|
console.log('start build.js script ...');
|
|
// Generate `build` object
|
|
const build = {};
|
|
const acDate = new Date();
|
|
const german = dayjs(acDate).tz('Europe/Berlin').format('DD.MM.YYYY HH:mm');
|
|
const texan = dayjs(acDate).tz('America/Chicago').format('L LT');
|
|
build.timestamp = `GER: ${german} | TX: ${texan}`;
|
|
// Write Build information to file
|
|
write(build);
|
|
console.log('build.js script finished ...');
|
|
})();
|