infraflow 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/infraflow.js +16 -1
- package/package.json +1 -1
package/bin/infraflow.js
CHANGED
|
@@ -15,6 +15,8 @@ const ORIGIN = (
|
|
|
15
15
|
process.env.INFRAFLOW_ORIGIN || "https://infraflow.app"
|
|
16
16
|
).replace(/\/+$/, "");
|
|
17
17
|
|
|
18
|
+
const VERSION = require("../package.json").version;
|
|
19
|
+
|
|
18
20
|
const SYSTEMS = { darwin: "darwin", linux: "linux", win32: "windows" };
|
|
19
21
|
const PROCESSORS = { x64: "x86_64", arm64: "aarch64" };
|
|
20
22
|
|
|
@@ -63,11 +65,24 @@ async function fetched(name, target) {
|
|
|
63
65
|
fs.renameSync(partial, target);
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
/** Removes the programs earlier versions of this package fetched. */
|
|
69
|
+
function forget(target) {
|
|
70
|
+
const dir = path.dirname(target);
|
|
71
|
+
for (const file of fs.readdirSync(dir)) {
|
|
72
|
+
if (file.startsWith("infraflow-") && file !== path.basename(target)) {
|
|
73
|
+
fs.rmSync(path.join(dir, file), { force: true });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
async function main() {
|
|
67
79
|
const name = asset();
|
|
68
|
-
|
|
80
|
+
// Kept under this package's version: updating the package fetches the
|
|
81
|
+
// program again, wherever the previous one was kept.
|
|
82
|
+
const target = home(name.replace("infraflow-", `infraflow-${VERSION}-`));
|
|
69
83
|
if (!fs.existsSync(target) || process.env.INFRAFLOW_REFETCH) {
|
|
70
84
|
await fetched(name, target);
|
|
85
|
+
forget(target);
|
|
71
86
|
}
|
|
72
87
|
const ran = spawnSync(target, process.argv.slice(2), { stdio: "inherit" });
|
|
73
88
|
if (ran.error) throw ran.error;
|
package/package.json
CHANGED