@t2code/cli 0.1.4-nightly.20261029.135 → 0.1.5
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/t2code.mjs +27 -2
- package/package.json +4 -1
package/bin/t2code.mjs
CHANGED
|
@@ -117,11 +117,36 @@ const isComplete = (dir) => {
|
|
|
117
117
|
function publish(staging, dir) {
|
|
118
118
|
try {
|
|
119
119
|
fs.renameSync(staging, dir);
|
|
120
|
+
return;
|
|
120
121
|
} catch (error) {
|
|
121
122
|
if (isComplete(dir)) return;
|
|
122
123
|
if (!fs.existsSync(dir)) throw error;
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
}
|
|
125
|
+
const lock = `${dir}.lock`;
|
|
126
|
+
try {
|
|
127
|
+
fs.mkdirSync(lock);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error.code !== "EEXIST") throw error;
|
|
130
|
+
throw new Error(
|
|
131
|
+
`another t3 is installing ${version}. If none is running, delete ${lock} and try again.`,
|
|
132
|
+
{ cause: error },
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
const stale = `${staging}.stale`;
|
|
136
|
+
try {
|
|
137
|
+
// A peer may have published between our marker check and taking the lock.
|
|
138
|
+
if (isComplete(dir)) return;
|
|
139
|
+
// Move it aside rather than deleting in place: once the folder is empty, a
|
|
140
|
+
// peer's first rename can land in it.
|
|
141
|
+
fs.renameSync(dir, stale);
|
|
142
|
+
try {
|
|
143
|
+
fs.renameSync(staging, dir);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (!isComplete(dir)) throw error;
|
|
146
|
+
}
|
|
147
|
+
} finally {
|
|
148
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
149
|
+
fs.rmSync(stale, { recursive: true, force: true });
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2code/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "T2 Code CLI. Downloads the self-contained executable for this platform from the GitHub Release.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,5 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20.11"
|
|
20
|
+
},
|
|
21
|
+
"t3code": {
|
|
22
|
+
"databaseMigration": 74
|
|
20
23
|
}
|
|
21
24
|
}
|