forked from haghish/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
githubmake.ado
61 lines (46 loc) · 1.48 KB
/
githubmake.ado
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
*cap prog drop githubmake
program githubmake
syntax anything [, replace]
// check that pkg and toc files do not already exist
/*
capture confirm file `"`anything'.pkg"'
if _rc == 0 {
}
*/
*tokenize `anything', parse("/")
*local username `1'
*local title `3'
local title `anything'
local capital : di ustrupper("`title'")
tempfile toctmp pkgtmp
tempname hitch knot toc pkg
// Creating the TOC file
// -------------------------------------------------------
qui file open `toc' using "`toctmp'", write replace
file write `toc' "d '`capital''" _n
file write `toc' "p `title'" _n
// Creating the PKG file
// -------------------------------------------------------
qui file open `pkg' using `"`pkgtmp'"', write replace
file write `pkg' "d '`capital''" _n "d " _n
local list : dir . files "*"
tokenize `"`list'"'
while `"`macval(1)'"' != "" {
if `"`macval(1)'"' != ".DS_Store" & ///
substr(`"`macval(1)'"', -4,.) != ".pkg" & ///
substr(`"`macval(1)'"', -4,.) != ".toc" & ///
`"`macval(1)'"' != "README.md" & `"`macval(1)'"' != "readme.md" ///
& `"`macval(1)'"' != "dependency.do" ///
& `"`macval(1)'"' != "params.json" ///
& `"`macval(1)'"' != "index.html" ///
& `"`macval(1)'"' != ".gitignore" ///
{
file write `pkg' `"F `1'"' _n
}
macro shift
}
file close `toc'
file close `pkg'
quietly copy "`toctmp'" "stata.toc", replace
quietly copy "`pkgtmp'" "`title'.pkg", replace
end