@localsummer/incspec 0.0.9 → 0.0.10
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/commands/archive.mjs +2 -1
- package/lib/spec.mjs +5 -5
- package/package.json +1 -1
package/commands/archive.mjs
CHANGED
|
@@ -122,7 +122,8 @@ function parseWorkflowTime(value) {
|
|
|
122
122
|
function isOutputArchived(archivedFiles, outputFile, completedAt) {
|
|
123
123
|
const ext = path.extname(outputFile);
|
|
124
124
|
const base = path.basename(outputFile, ext);
|
|
125
|
-
|
|
125
|
+
// Match: base.ext, base-2.ext, base-3.ext, ...
|
|
126
|
+
const pattern = new RegExp(`^${escapeRegExp(base)}(-\\d+)?${escapeRegExp(ext)}$`);
|
|
126
127
|
return archivedFiles.some(file => pattern.test(file.name) && file.mtime >= completedAt);
|
|
127
128
|
}
|
|
128
129
|
|
package/lib/spec.mjs
CHANGED
|
@@ -21,13 +21,13 @@ function ensureUniqueArchivePath(filePath) {
|
|
|
21
21
|
const dir = path.dirname(filePath);
|
|
22
22
|
const ext = path.extname(filePath);
|
|
23
23
|
const base = path.basename(filePath, ext);
|
|
24
|
-
let counter =
|
|
25
|
-
let candidate
|
|
24
|
+
let counter = 2;
|
|
25
|
+
let candidate;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
candidate = path.join(dir, `${base}
|
|
27
|
+
do {
|
|
28
|
+
candidate = path.join(dir, `${base}-${counter}${ext}`);
|
|
29
29
|
counter += 1;
|
|
30
|
-
}
|
|
30
|
+
} while (fs.existsSync(candidate));
|
|
31
31
|
|
|
32
32
|
return candidate;
|
|
33
33
|
}
|