deno.land / x / enviromodder@1.0.6 / setup / mk_setup.ts

نووسراو ببینە
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import cloneTemplateToCache from "./clone.ts"; import { configDir, path, fs } from "./deps.ts";
const name = Deno.args[0] ?? "." const refIndex = Deno.args.findIndex(e => e === "--version" || e === "-v")let ref = refIndex !== -1 ? Deno.args[refIndex + 1] : undefined
const currentFolder = Deno.cwd();
const destFolder = path.join(currentFolder, name)
if (name !== ".") await Deno.mkdir(destFolder)
const userDir = configDir();
if (!userDir) { console.error("Unable to find user config directory!"); Deno.exit(1);}
const remapperDirectory = path.join(userDir, "remapper_setup")
if (!ref) { const latestRelease = await fetch("https://api.github.com/repos/Splashcard04/Map-Key/releases/latest", { headers: { "Accept": "application/vnd.github+json" } }) if (latestRelease.status != 200) { console.error(`Received error ${latestRelease.status} while fetching latest release name`) Deno.exit(2) } const json = await latestRelease.json() ref = json["tag_name"]!}
if (!ref) { console.error(`No ref specified`) Deno.exit(2)}
try { await Deno.mkdir(remapperDirectory, { recursive: true })} catch (e) { if (e! instanceof Deno.errors.AlreadyExists) throw e;} const templatePath = path.join(remapperDirectory, ref)
try { await Deno.stat(templatePath)} catch (e) { if (e instanceof Deno.errors.NotFound) { await cloneTemplateToCache(templatePath, ref); } else { throw e; }}
// Validate the path existsawait Deno.stat(templatePath)
// now copy to pathconst ignoredFiles = ["setup", ".git", "README.md", ".gitignore", "test", "LICENSE", "ExampleMaps.md"]
const tasks: Promise<void>[] = []
for await (const file of Deno.readDir(templatePath)) { if (ignoredFiles.includes(file.name)) continue

const src = path.join(templatePath, file.name) const dest = path.join(destFolder, file.name)
tasks.push(fs.copy(src, dest))}
await Promise.all(tasks)
console.log(`setup from map key complete at ${destFolder} , Thanks for useing my really dumb package :D`)
enviromodder

Version Info

Tagged at
a year ago