-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathpackage.ps1
More file actions
51 lines (46 loc) · 1.21 KB
/
Copy pathpackage.ps1
File metadata and controls
51 lines (46 loc) · 1.21 KB
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
# concatenates files
$targets = @{
"editor.js" = @(
"dwachss/historystack/history.js",
"dwachss/keymap/keymap.js",
"dwachss/status/status.js",
"dwachss/toolbar/toolbar.js",
"bililiteRange.js",
"bililiteRange.undo.js",
"bililiteRange.lines.js",
"bililiteRange.find.js",
"bililiteRange.ex.js",
"bililiteRange.evim.js"
);
"bililiteRange.js" = @(
"bililiteRange.js",
"bililiteRange.find.js"
)
}
$shaSize = 7
function Get-Sha {
param($repo)
if ($repo) {
[char[]]((Invoke-WebRequest https://api.github.com/repos/$repo/commits/master -Headers @{Accept = 'application/vnd.github.sha'}).Content[0..$shaSize]) -join ''
}else{
git rev-parse --short=$shaSize HEAD
}
}
function Get-Source-Content {
param($repo, $file)
if ($repo){
(Invoke-WebRequest https://raw.githubusercontent.com/$repo/master/$file).Content
}else{
Get-Content $file
}
}
foreach ($target in $targets.Keys){
"// $target $( Get-Date -Format 'yyyy-MM-dd')" > dist/$target
foreach ($source in $targets[$target]){
$repo = (Split-Path $source) -replace '\\', '/'
$file = Split-Path $source -leaf
"" >> dist/$target
"// $source commit $(Get-Sha $repo)" >> dist/$target
Get-Source-Content $repo $file >> dist/$target
}
}