-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathgenerate.ls
More file actions
executable file
·33 lines (30 loc) · 898 Bytes
/
Copy pathgenerate.ls
File metadata and controls
executable file
·33 lines (30 loc) · 898 Bytes
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
fs = require \fs
glob = require \glob
p = require \prelude-ls
is-file= (name)->
fs.exists-sync(name) and fs.lstat-sync(name).is-file!
update-json = (path, update)->
file = if is-file(path) then require(path) else {}
save = ->
fs.write-file-sync(path, json, \utf8)
update file, save
json = JSON.stringify(file, null, 4)
save!
files = glob.sync \compiled-commands/*
update-json do
* \./package.json
* (model)->
name = (filename)->
filename.match("([a-z]+).[^.]+$").1
ref = ->
"./refs/#it"
names =
files |> p.map name
names.for-each (it)->
fs.write-file-sync do
*ref it
* "#!/usr/bin/env node\nrequire('../nixar.js')('#it')"
* \utf8
model.bin =
names |> p.map (-> [it, ref it])
|> p.pairs-to-obj