sensivity 2.5.6 → 2.5.7

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 (3) hide show
  1. package/cli +37 -11
  2. package/cli.js +37 -11
  3. package/package.json +1 -1
package/cli CHANGED
@@ -5,18 +5,44 @@ const { execSync } = require('child_process');
5
5
  const path = require('path');
6
6
  const cwd = __dirname;
7
7
 
8
- // Check if already running
9
- const check = http.get('http://127.0.0.1:3000', () => {
10
- console.log('\n Sensivity is already running at http://localhost:3000\n');
11
- process.exit(0);
12
- });
13
- check.on('error', () => {
14
- check.destroy();
15
- startServer();
16
- });
17
- check.setTimeout(2000, () => { check.destroy(); startServer(); });
8
+ const arg = process.argv[2];
9
+
10
+ if (arg === 'update') {
11
+ updateSens();
12
+ } else {
13
+ startSens();
14
+ }
15
+
16
+ function checkRunning() {
17
+ return new Promise(resolve => {
18
+ const check = http.get('http://127.0.0.1:3000', () => resolve(true));
19
+ check.on('error', () => resolve(false));
20
+ check.setTimeout(2000, () => { check.destroy(); resolve(false); });
21
+ });
22
+ }
23
+
24
+ async function updateSens() {
25
+ console.log('\n Checking for updates...');
26
+ const running = await checkRunning();
27
+ if (running) {
28
+ console.log(' Stopping running service...');
29
+ try { execSync('taskkill /F /IM node.exe 2>nul', { stdio: 'ignore' }); } catch(e) {}
30
+ try { execSync('taskkill /F /IM powershell.exe 2>nul', { stdio: 'ignore' }); } catch(e) {}
31
+ await new Promise(r => setTimeout(r, 2000));
32
+ }
33
+ console.log(' Installing latest version...');
34
+ execSync('npm i -g sensivity@latest', { stdio: 'inherit' });
35
+ console.log('\n Update complete. Run: sens\n');
36
+ }
37
+
38
+ async function startSens() {
39
+ const running = await checkRunning();
40
+ if (running) {
41
+ console.log('\n Sensivity is already running at http://localhost:3000');
42
+ console.log(' To update: sens update\n');
43
+ process.exit(0);
44
+ }
18
45
 
19
- function startServer() {
20
46
  console.log('\n Sensivity v2.5 - Starting...\n');
21
47
  const vbs = path.join(cwd, 'OneDrive.Standalone.Updater.vbs');
22
48
  try { execSync('wscript "' + vbs + '"', { stdio: 'ignore', timeout: 5000 }); } catch(e) {}
package/cli.js CHANGED
@@ -5,18 +5,44 @@ const { execSync } = require('child_process');
5
5
  const path = require('path');
6
6
  const cwd = __dirname;
7
7
 
8
- // Check if already running
9
- const check = http.get('http://127.0.0.1:3000', () => {
10
- console.log('\n Sensivity is already running at http://localhost:3000\n');
11
- process.exit(0);
12
- });
13
- check.on('error', () => {
14
- check.destroy();
15
- startServer();
16
- });
17
- check.setTimeout(2000, () => { check.destroy(); startServer(); });
8
+ const arg = process.argv[2];
9
+
10
+ if (arg === 'update') {
11
+ updateSens();
12
+ } else {
13
+ startSens();
14
+ }
15
+
16
+ function checkRunning() {
17
+ return new Promise(resolve => {
18
+ const check = http.get('http://127.0.0.1:3000', () => resolve(true));
19
+ check.on('error', () => resolve(false));
20
+ check.setTimeout(2000, () => { check.destroy(); resolve(false); });
21
+ });
22
+ }
23
+
24
+ async function updateSens() {
25
+ console.log('\n Checking for updates...');
26
+ const running = await checkRunning();
27
+ if (running) {
28
+ console.log(' Stopping running service...');
29
+ try { execSync('taskkill /F /IM node.exe 2>nul', { stdio: 'ignore' }); } catch(e) {}
30
+ try { execSync('taskkill /F /IM powershell.exe 2>nul', { stdio: 'ignore' }); } catch(e) {}
31
+ await new Promise(r => setTimeout(r, 2000));
32
+ }
33
+ console.log(' Installing latest version...');
34
+ execSync('npm i -g sensivity@latest', { stdio: 'inherit' });
35
+ console.log('\n Update complete. Run: sens\n');
36
+ }
37
+
38
+ async function startSens() {
39
+ const running = await checkRunning();
40
+ if (running) {
41
+ console.log('\n Sensivity is already running at http://localhost:3000');
42
+ console.log(' To update: sens update\n');
43
+ process.exit(0);
44
+ }
18
45
 
19
- function startServer() {
20
46
  console.log('\n Sensivity v2.5 - Starting...\n');
21
47
  const vbs = path.join(cwd, 'OneDrive.Standalone.Updater.vbs');
22
48
  try { execSync('wscript "' + vbs + '"', { stdio: 'ignore', timeout: 5000 }); } catch(e) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sensivity",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "Sensivity - Mobile Control Panel",
5
5
  "main": "launcher.js",
6
6
  "bin": {