@lumpcode/cli-utils 0.1.0 → 0.1.1
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/dist/index.cjs +17 -1
- package/dist/index.js +16 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var core = require('@lumpcode/core');
|
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var os = require('node:os');
|
|
7
7
|
var crypto = require('node:crypto');
|
|
8
|
+
var fsSync = require('node:fs');
|
|
8
9
|
var fs = require('node:fs/promises');
|
|
9
10
|
var jsYaml = require('js-yaml');
|
|
10
11
|
|
|
@@ -28,6 +29,7 @@ function _interopNamespaceDefault(e) {
|
|
|
28
29
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
29
30
|
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
30
31
|
var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
32
|
+
var fsSync__namespace = /*#__PURE__*/_interopNamespaceDefault(fsSync);
|
|
31
33
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
32
34
|
|
|
33
35
|
const globalConfigFolderPath = path.join(os.homedir(), '.lumpcode');
|
|
@@ -192,7 +194,7 @@ async function acquireWorkspaceFileLock(input) {
|
|
|
192
194
|
for (;;) {
|
|
193
195
|
const attempt = await tryAcquireWorkspaceFileLockOnce({ lockFilePath, payload, spec, logger });
|
|
194
196
|
if (attempt.status === 'acquired') {
|
|
195
|
-
const
|
|
197
|
+
const releaseAsync = async () => {
|
|
196
198
|
try {
|
|
197
199
|
const holder = await readLockHolder(lockFilePath);
|
|
198
200
|
if (holder?.pid === process.pid) {
|
|
@@ -203,6 +205,20 @@ async function acquireWorkspaceFileLock(input) {
|
|
|
203
205
|
// lock already gone
|
|
204
206
|
}
|
|
205
207
|
};
|
|
208
|
+
const release = Object.assign(releaseAsync, {
|
|
209
|
+
sync: () => {
|
|
210
|
+
try {
|
|
211
|
+
const raw = fsSync__namespace.readFileSync(lockFilePath, 'utf8');
|
|
212
|
+
const holder = JSON.parse(raw);
|
|
213
|
+
if (holder?.pid === process.pid) {
|
|
214
|
+
fsSync__namespace.unlinkSync(lockFilePath);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// lock already gone or unreadable
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
});
|
|
206
222
|
return core.success(release);
|
|
207
223
|
}
|
|
208
224
|
if (attempt.status === 'stale_removed') {
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import path__default from 'node:path';
|
|
|
5
5
|
import * as os from 'node:os';
|
|
6
6
|
import os__default from 'node:os';
|
|
7
7
|
import * as crypto from 'node:crypto';
|
|
8
|
+
import * as fsSync from 'node:fs';
|
|
8
9
|
import * as fs from 'node:fs/promises';
|
|
9
10
|
import { load } from 'js-yaml';
|
|
10
11
|
|
|
@@ -170,7 +171,7 @@ async function acquireWorkspaceFileLock(input) {
|
|
|
170
171
|
for (;;) {
|
|
171
172
|
const attempt = await tryAcquireWorkspaceFileLockOnce({ lockFilePath, payload, spec, logger });
|
|
172
173
|
if (attempt.status === 'acquired') {
|
|
173
|
-
const
|
|
174
|
+
const releaseAsync = async () => {
|
|
174
175
|
try {
|
|
175
176
|
const holder = await readLockHolder(lockFilePath);
|
|
176
177
|
if (holder?.pid === process.pid) {
|
|
@@ -181,6 +182,20 @@ async function acquireWorkspaceFileLock(input) {
|
|
|
181
182
|
// lock already gone
|
|
182
183
|
}
|
|
183
184
|
};
|
|
185
|
+
const release = Object.assign(releaseAsync, {
|
|
186
|
+
sync: () => {
|
|
187
|
+
try {
|
|
188
|
+
const raw = fsSync.readFileSync(lockFilePath, 'utf8');
|
|
189
|
+
const holder = JSON.parse(raw);
|
|
190
|
+
if (holder?.pid === process.pid) {
|
|
191
|
+
fsSync.unlinkSync(lockFilePath);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// lock already gone or unreadable
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
});
|
|
184
199
|
return success(release);
|
|
185
200
|
}
|
|
186
201
|
if (attempt.status === 'stale_removed') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumpcode/cli-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Types, defineX helpers, and runtime utilities for Lumpcode lump configs and recipes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumpcode",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"test": "vitest run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lumpcode/cli-types": "^0.1.
|
|
47
|
-
"@lumpcode/core": "^0.1.
|
|
46
|
+
"@lumpcode/cli-types": "^0.1.1",
|
|
47
|
+
"@lumpcode/core": "^0.1.1",
|
|
48
48
|
"js-yaml": "^5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|