-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (49 loc) · 1.59 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import fs from 'fs';
import path from 'path';
import chalk from "chalk";
import log from "./src/log.js"
import install from "./src/install.js"
import uninstall from "./src/uninstall.js"
import { picker } from "./src/picker.js"
import setup from "./src/setup.js"
async function endPoint(argument) {
// body...
// check if a config file is present
let config = "/data/data/com.termux/files/home/acode.config.json"
let isConfig = fs.existsSync(path.resolve(config))
log(chalk.gray.underline(" checking for config"))
if (isConfig) {
log(chalk.green(" found it"))
log(chalk.white(" what snippet do you want to install?"))
let configData = fs.readFileSync(config, "utf-8")
configData = JSON.parse(configData)
let chose = await picker(configData)
install(chose, configData)
} else {
log(chalk.red(" config file not found :("))
setup(endPoint)
}
// log(process.argv.slice(2))
}
async function removeEndPoint(argument) {
// body...
let config = "/data/data/com.termux/files/home/acode.config.json"
let isConfig = fs.existsSync(path.resolve(config))
log(chalk.gray.underline(" checking for config"))
if (isConfig) {
log(chalk.green(" found it"))
log(chalk.white(" what snippet do you want to uninstall?"))
let configData = fs.readFileSync(config, "utf-8")
configData = JSON.parse(configData)
let chose = await picker(configData)
// log(chose)
uninstall(chose, configData.snippets)
} else {
log(chalk.red(" config file not found :("))
setup(removeEndPoint)
}
}
// function fixe() {
// setup()
// }
export { endPoint, removeEndPoint }