forked from ljacobsson/samp-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·37 lines (31 loc) · 1.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
process.env.AWS_SDK_LOAD_CONFIG = 1;
const program = require("commander");
const package = require("./package.json");
const fs = require("fs");
const path = require("path");
const axios = require("axios").default;
const commands = fs.readdirSync(path.join(__dirname, "src", "commands"));
for (const command of commands) {
require(`./src/commands/${command}`);
}
program.version(package.version, "-v, --vers", "output the current version");
(async () => {
try {
const now = new Date();
const latestVersion = await axios.get("https://api.github.com/repos/ljacobsson/samp-cli/releases/latest", { timeout: 300 })
if (latestVersion.data.tag_name !== package.version) {
console.log(`\nUpdate available: ${latestVersion.data.tag_name}. You are using ${package.version}.\nRun "npm i -g samp-cli" to update.\n`);
}
} catch (error) {
} finally {
program.parse(process.argv);
}
})();
if (process.argv.length < 3) {
program.help();
}
// nodejs<15 compatability
String.prototype.replaceAll = function (target, replacement) {
return this.split(target).join(replacement);
};