const replace = require("replace-in-file");
const gitHash = require("child_process")
  .execSync("git rev-parse --short HEAD")
  .toString()
  .trim();

const options = {
  files: "dist/static/vue/*.js",
  from: /VBV_VERSION_BUILD_NUMBER_VBV/g,
  to: new Date().toISOString().replace("T", " ").substring(0, 19) + " " + gitHash,
};

replace(options, (error, results) => {
  if (error) {
    return console.error("Versionize Error occurred:", error);
  }
  console.log(`Versionized ${results.filter((f) => f.hasChanged).length} files`);
});
