-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add-添加所有集得源.ps1
100 lines (54 loc) · 3.11 KB
/
Add-添加所有集得源.ps1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
# 绝大多数情形下,
# 使用者仅需关注本文件的 PROCESS 一节,
# 而完全不必触碰 BEGIN 、 END 两节。
#
# 顺便提醒,即便故意将 PROCESS 一节写在 BEGIN 之前,或写在 END 之后,
# PowerShell 语言的原生机制也会
# 强制三者依照先 BEGIN ,而后 PROCESS ,最后 END 的顺序执行。
# 为便于修订本文件,遂故意令 PROCESS 一节在最顶部。
PROCESS {
Try {
Add-吴乐川添加单个集得源 -集得源在本机采用的名称 '吴乐川:码云' `
-特征颜色 'DarkRed' -集得源之完整地址 'git@gitee.com:nanchang-wulechuan/wulechuan--cli-scripts--git-push.git'
Add-吴乐川添加单个集得源 -集得源在本机采用的名称 '吴乐川:阿里云' `
-特征颜色 'Blue' -集得源之完整地址 'git@code.aliyun.com:wulechuan/wulechuan--cli-scripts--git-push.git'
Add-吴乐川添加单个集得源 -集得源在本机采用的名称 '吴乐川:GitHub' `
-特征颜色 'Yellow' -集得源之完整地址 'git@github.com:wulechuan/wulechuan--cli-scripts--git-push.git'
} catch {
${private:RunTimeException} = $_
}
}
BEGIN {
# 该名为 BEGIN 之代码块故意安排在 PROCESS 代码块之后。但实际上 BEGIN 会在 PROCESS 之前运行。
${private:RunTimeException} = $null
[string]${private:执行本命令前的工作路径} = "$PWD"
Write-Host "`n【当下工作路径】:`n '$PWD'"
if ("$PWD" -match "\\用于研发阶段的命令行工具集\\PowerShell`$") {
${private:执行本命令前的工作路径} = "$PWD"
Set-Location '..\..\' # 确保进程的当前路径为接受本工具集服务的 npm 包的根文件夹。
Write-Host "`n【当下工作路径】临时变更为:`n '$PWD'"
}
Write-Host
Write-Host
Write-Host
# 下方这一行的写法专门针对本工具集自身,不适应于其他任何 npm 项。
[string]${script:吴乐川的模块的路径} = '.\源代码\发布的源代码\PowerShell'
# 在采用本工具集的其他 npm 项目中,应这样写:
# [string]${script:吴乐川的模块的路径} = '.\node_modules\@wulechuan\cli-scripts--git-push\源代码\发布的源代码\PowerShell'
Import-Module "${script:吴乐川的模块的路径}\吴乐川-数据处理-文本.psm1"
Import-Module "${script:吴乐川的模块的路径}\吴乐川-内容呈现.psm1"
Import-Module "${script:吴乐川的模块的路径}\吴乐川-集得源管理工具集.psm1"
}
END {
if (${private:执行本命令前的工作路径} -and ("${private:执行本命令前的工作路径}" -ne "$PWD")) {
Set-Location "${private:执行本命令前的工作路径}"
Write-Host "`n【当下工作路径】已复原。"
}
if (${private:RunTimeException}) {
Write-Host
Write-Host -F 'Red' '执行过程曾出错。'
Write-Host
throw ${private:RunTimeException}
}
}