1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +01:00
excalidraw/scripts/build-version.js

38 lines
771 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const asar = require("asar");
const zero = digit => `0${digit}`.slice(-2);
const versionDate = date => {
const date_ = `${date.getFullYear()}-${zero(date.getMonth() + 1)}-${zero(
date.getDate(),
)}`;
const time = `${zero(date.getHours())}-${zero(date.getMinutes())}-${zero(
date.getSeconds(),
)}`;
return `${date_}-${time}`;
};
const now = new Date();
const data = JSON.stringify(
{
2020-02-29 16:23:09 +01:00
asar: `excalidraw.asar`,
version: versionDate(now),
},
undefined,
2,
);
fs.writeFileSync(path.join("build", "version.json"), data);
(async () => {
const src = "build/";
2020-02-29 16:23:09 +01:00
const dest = path.join("build", `excalidraw.asar`);
await asar.createPackage(src, dest);
})();