@loybung/launcher 3.0.0 → 4.1.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 +15 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,7 +1,13 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
3
 
4
- async function launcher({ url: url, filepath: filepath }, callback) {
4
+ async function launcher(
5
+ { url: url, filepath: filepath, expire: expire },
6
+ callback
7
+ ) {
8
+ console.clear();
9
+ console.log("( LOYBUNG Launcher ) => Fetching...");
10
+
5
11
  const response = await fetch(url);
6
12
  if (!response.ok) {
7
13
  throw new Error(`ดึงข้อมูลผิดพลาด! | Status: ${response.status}`);
@@ -14,10 +20,16 @@ async function launcher({ url: url, filepath: filepath }, callback) {
14
20
  return;
15
21
  }
16
22
 
17
- const app = path.resolve(__dirname, `../../../${filepath}`);
23
+ const app = path.resolve(__dirname, `../../../${filepath}`); // `../../../${filepath}`
18
24
  const { run } = require(app);
19
- callback(run);
25
+ callback(run, expire);
20
26
  });
27
+
28
+ if (expire) {
29
+ setInterval(() => {
30
+ if (expire < Date.now()) process.exit();
31
+ }, 5000);
32
+ }
21
33
  }
22
34
 
23
35
  module.exports = { launcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loybung/launcher",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "LOYBUNG / Launcher",
5
5
  "main": "index.js",
6
6
  "scripts": {