mirror of
https://github.com/keyboardio/Chrysalis.git
synced 2026-02-28 19:07:17 +01:00
The goal of this preinstall script is to add a build number to the package version within our CI environment. Outside of CI, it should do nothing. However, it was unconditionally overwriting `package.json`, with a version that has no trailing newline. That's an issue, because most editors will add one, so running `yarn install` always removed that, ending up with the change making the git working directory dirty. As there is no reason to save the file when we're not running in the CI environment, move the writing inside the if branch. We don't care if the working tree becomes dirty in CI, it will be discarded anyway. Not running unconditionally will stop newlines getting removed, and make development that much less annoying. Signed-off-by: Gergely Nagy <algernon@keyboard.io>
13 lines
493 B
JavaScript
13 lines
493 B
JavaScript
const package = require("../package.json");
|
|
const fs = require("fs");
|
|
|
|
if (process.env.GITHUB_RUN_NUMBER &&
|
|
package.version.indexOf("-snapshot") != -1 &&
|
|
package.version.indexOf("-snapshot.") == -1) {
|
|
package.version = package.version + "." + process.env.GITHUB_RUN_NUMBER;
|
|
package.build.artifactName = "${productName}-" + package.version + ".${ext}";
|
|
console.log("package.version = ", package.version);
|
|
|
|
fs.writeFileSync("./package.json", JSON.stringify(package, null, 2));
|
|
}
|