-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ts
29 lines (22 loc) · 793 Bytes
/
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
import { format } from 'https://deno.land/[email protected]/datetime/mod.ts'
let [day, year] = format(new Date(), 'd,yyyy').split(',')
if (Deno.args[0] && Deno.args[1]) {
year = Deno.args[0]
day = Deno.args[1]
} else if (Deno.args[0] || Deno.args[1]) {
console.log('Invalid arguments')
Deno.exit(1)
}
const dir = `${year}/${day.padStart(2, '0')}`
const encoder = new TextEncoder()
const data =
encoder.encode(`import * as p from 'https://deno.land/[email protected]/path/mod.ts'
const input = await Deno.readTextFile(
p.fromFileUrl(import.meta.resolve('./input.txt'))
)
const lines = input.trimEnd().split('\\n')
`)
await Deno.mkdir(dir, { recursive: true })
await Deno.create(`./${dir}/input.txt`)
await Deno.writeFile(`./${dir}/1.ts`, data)
await Deno.writeFile(`./${dir}/2.ts`, data)