endef 2.0.4 → 2.0.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/README.md +1 -0
- package/package.json +1 -1
- package/src/de.js +34 -6
- package/src/en.js +3 -1
- package/src/run.js +6 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/de.js
CHANGED
|
@@ -86,7 +86,14 @@ find "\${find_args[@]}" | xargs -0 -r -P "$jobs" -I{} bash -c '
|
|
|
86
86
|
maxBuffer: 1024 * 1024 * 64,
|
|
87
87
|
windowsHide: true
|
|
88
88
|
})
|
|
89
|
-
const
|
|
89
|
+
const restoredFiles = splitNullSeparated(stdout)
|
|
90
|
+
const restored = restoredFiles.length
|
|
91
|
+
|
|
92
|
+
if (config.verbose) {
|
|
93
|
+
restoredFiles.forEach(file => {
|
|
94
|
+
console.log(`Restored: ${file}`)
|
|
95
|
+
})
|
|
96
|
+
}
|
|
90
97
|
|
|
91
98
|
console.log(`Done. mode=bash, restored=${restored}, failed=0`)
|
|
92
99
|
return {
|
|
@@ -118,10 +125,12 @@ $root = $env:ENDEF_ROOT
|
|
|
118
125
|
$suffix = $env:ENDEF_SUFFIX
|
|
119
126
|
$excludeText = $env:ENDEF_EXCLUDE_DIRS
|
|
120
127
|
$excludeDirs = @()
|
|
128
|
+
$verbose = $env:ENDEF_VERBOSE -eq '1'
|
|
121
129
|
if ($excludeText) {
|
|
122
130
|
$excludeDirs = $excludeText -split "\\n" | Where-Object { $_ }
|
|
123
131
|
}
|
|
124
132
|
$restored = 0
|
|
133
|
+
$restoredFiles = New-Object System.Collections.Generic.List[string]
|
|
125
134
|
Get-ChildItem -LiteralPath $root -Recurse -File -Filter "*$suffix" | Where-Object {
|
|
126
135
|
$cleanRoot = $root.TrimEnd('\\', '/')
|
|
127
136
|
$relative = $_.FullName.Substring($cleanRoot.Length).TrimStart('\\', '/')
|
|
@@ -139,6 +148,14 @@ Get-ChildItem -LiteralPath $root -Recurse -File -Filter "*$suffix" | Where-Objec
|
|
|
139
148
|
Remove-Item -LiteralPath $target -Force -ErrorAction SilentlyContinue
|
|
140
149
|
Move-Item -LiteralPath $_.FullName -Destination $target -Force
|
|
141
150
|
$restored += 1
|
|
151
|
+
if ($verbose) {
|
|
152
|
+
$restoredFiles.Add($target)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if ($verbose) {
|
|
156
|
+
foreach ($file in $restoredFiles) {
|
|
157
|
+
Write-Output "Restored: $file"
|
|
158
|
+
}
|
|
142
159
|
}
|
|
143
160
|
Write-Output $restored
|
|
144
161
|
`
|
|
@@ -157,13 +174,21 @@ Write-Output $restored
|
|
|
157
174
|
...process.env,
|
|
158
175
|
ENDEF_ROOT: config.directory,
|
|
159
176
|
ENDEF_SUFFIX: config.suffix,
|
|
160
|
-
ENDEF_EXCLUDE_DIRS: config.excludeDirs.join('\n')
|
|
177
|
+
ENDEF_EXCLUDE_DIRS: config.excludeDirs.join('\n'),
|
|
178
|
+
ENDEF_VERBOSE: config.verbose ? '1' : ''
|
|
161
179
|
},
|
|
162
180
|
maxBuffer: 1024 * 1024 * 64,
|
|
163
181
|
windowsHide: true
|
|
164
182
|
}
|
|
165
183
|
)
|
|
166
|
-
const
|
|
184
|
+
const lines = stdout.trim().split(/\r?\n/).filter(Boolean)
|
|
185
|
+
const restored = Number(lines[lines.length - 1]) || 0
|
|
186
|
+
|
|
187
|
+
if (config.verbose) {
|
|
188
|
+
lines.slice(0, -1).forEach(line => {
|
|
189
|
+
console.log(line)
|
|
190
|
+
})
|
|
191
|
+
}
|
|
167
192
|
|
|
168
193
|
console.log(`Done. mode=powershell, restored=${restored}, failed=0`)
|
|
169
194
|
return {
|
|
@@ -213,6 +238,9 @@ async function restoreNodeDirectory(directory, config, stats) {
|
|
|
213
238
|
await fs.rm(targetPath, { force: true })
|
|
214
239
|
await fs.rename(filePath, targetPath)
|
|
215
240
|
stats.restored += 1
|
|
241
|
+
if (config.verbose) {
|
|
242
|
+
console.log(`Restored: ${targetPath}`)
|
|
243
|
+
}
|
|
216
244
|
} catch (error) {
|
|
217
245
|
stats.failed += 1
|
|
218
246
|
console.error(`Failed: ${filePath}`)
|
|
@@ -222,12 +250,12 @@ async function restoreNodeDirectory(directory, config, stats) {
|
|
|
222
250
|
)
|
|
223
251
|
}
|
|
224
252
|
|
|
225
|
-
function
|
|
253
|
+
function splitNullSeparated(value) {
|
|
226
254
|
if (!value) {
|
|
227
|
-
return
|
|
255
|
+
return []
|
|
228
256
|
}
|
|
229
257
|
|
|
230
|
-
return value.split('\0').filter(Boolean)
|
|
258
|
+
return value.split('\0').filter(Boolean)
|
|
231
259
|
}
|
|
232
260
|
|
|
233
261
|
module.exports = restoreFiles
|
package/src/en.js
CHANGED
|
@@ -30,7 +30,9 @@ async function processFiles(directory, options = {}) {
|
|
|
30
30
|
const data = await fs.readFile(filePath)
|
|
31
31
|
|
|
32
32
|
await fs.writeFile(outputPath, data)
|
|
33
|
-
|
|
33
|
+
if (config.verbose) {
|
|
34
|
+
console.log(`Written: ${outputPath}`)
|
|
35
|
+
}
|
|
34
36
|
stats.written += 1
|
|
35
37
|
}).catch(error => {
|
|
36
38
|
stats.failed += 1
|
package/src/run.js
CHANGED
|
@@ -18,6 +18,7 @@ Options:
|
|
|
18
18
|
--concurrency <n> Concurrent file operation limit
|
|
19
19
|
--out <file> Archive output name
|
|
20
20
|
--mode <mode> Restore mode for de/all: auto, bash, powershell, node
|
|
21
|
+
--verbose Print each processed file
|
|
21
22
|
`)
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -96,6 +97,11 @@ function parseArgs(command, args) {
|
|
|
96
97
|
continue
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
if (arg === '--verbose') {
|
|
101
|
+
result.verbose = true
|
|
102
|
+
continue
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
if (arg.startsWith('--mode=')) {
|
|
100
106
|
result.restoreMode = arg.slice('--mode='.length)
|
|
101
107
|
continue
|