@loybung/launcher 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +23 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ const fs = require("fs");
2
+
3
+ async function launcher({ url: url, filepath: filepath }, callback) {
4
+ const response = await fetch(url);
5
+ if (!response.ok) {
6
+ throw new Error(`ดึงข้อมูลผิดพลาด! | Status: ${response.status}`);
7
+ }
8
+ const textData = await response.text();
9
+
10
+ fs.writeFile(filepath, textData, "utf8", (err) => {
11
+ if (err) {
12
+ console.error("เกิดข้อผิดพลาดในการเขียนไฟล์:", err);
13
+ return;
14
+ }
15
+
16
+ fs.readFile(filepath, "utf8", (err, data) => {
17
+ const { run } = require(`${filepath}`);
18
+ callback(run);
19
+ });
20
+ });
21
+ }
22
+
23
+ module.exports = { launcher };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@loybung/launcher",
3
+ "version": "1.0.0",
4
+ "description": "LOYBUNG / Launcher",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "loybung <loybung@hotmail.com> (https://discord.gg/XDPfrU4E9G)",
11
+ "license": "ISC"
12
+ }