deno.land / x / deno_hello_world@v.0.0.11 / init / main.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
import * as path from "https://deno.land/std@0.165.0/path/mod.ts";import * as fs from "https://deno.land/std@0.165.0/fs/mod.ts";
const initPath = path.dirname(path.fromFileUrl(import.meta.url));
const resources = [ { read: "../content/test.json", write: "/test.json", }, { read: "../content/test.ts", write: "/test.ts" },];
export async function initProject(folder: string, name: string) { const root = path.join(folder, name); if (await fs.exists(root)) { console.error(`directory exist, please delete it first: ${root}`); return null; } console.log("generating..."); await fs.ensureDir(root); for (const resource of resources) { const fp_read = path.join(initPath, resource.read); const fp_write = path.join(root, resource.write); console.log(root, fp_read, fp_write); await fs.ensureFile(fp_read); const bytes = await Deno.readFile(fp_read); console.log(fp_read, bytes); await Deno.writeFile(fp_write, bytes); } console.log("done.");}
deno_hello_world

Version Info

Tagged at
a year ago