You've already forked hugo-extended
mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2026-06-12 08:45:27 -04:00
fix: EPERM permission issues on windows tests
This commit is contained in:
@@ -28,10 +28,6 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: npm ci
|
||||
env:
|
||||
DEBUG: careful-downloader
|
||||
DEBUG_HIDE_DATE: 1
|
||||
DEBUG_COLORS: 0
|
||||
- run: npm audit --omit=dev
|
||||
continue-on-error: true
|
||||
- run: npm run test
|
||||
|
||||
+27
-8
@@ -11,13 +11,17 @@ it("Hugo exists and runs?", async function () {
|
||||
|
||||
const hugoPath = await hugo();
|
||||
|
||||
assert(execFile(hugoPath, ["env"], function (error, stdout) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(stdout);
|
||||
}));
|
||||
// Wrap execFile in a Promise to ensure it completes before the test finishes
|
||||
await new Promise((resolve, reject) => {
|
||||
execFile(hugoPath, ["env"], function (error, stdout) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
console.log(stdout);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Hugo doesn't exist, install it instead of throwing an error", async function () {
|
||||
@@ -32,7 +36,22 @@ it("Hugo doesn't exist, install it instead of throwing an error", async function
|
||||
}
|
||||
|
||||
// delete binary to ensure it's auto-reinstalled
|
||||
await deleteAsync(path.dirname(getBinPath()), { force: true });
|
||||
// Note: On Windows, we delete the specific file because deleting the directory often causes EPERM/locking issues
|
||||
if (process.platform === "win32") {
|
||||
// Retry logic for Windows EPERM issues
|
||||
const maxRetries = 5;
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
try {
|
||||
await deleteAsync(getBinPath(), { force: true });
|
||||
break;
|
||||
} catch (err) {
|
||||
if (i === maxRetries - 1) throw err;
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await deleteAsync(path.dirname(getBinPath()), { force: true });
|
||||
}
|
||||
|
||||
const hugoPath = await hugo();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user