@mindbase/deploy 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ssh/executor.ts +14 -2
package/package.json
CHANGED
package/src/ssh/executor.ts
CHANGED
|
@@ -4,8 +4,20 @@ import type SftpClient from 'ssh2-sftp-client';
|
|
|
4
4
|
* 在远程服务器执行命令
|
|
5
5
|
*/
|
|
6
6
|
export async function execRemote(sftp: SftpClient, command: string): Promise<string> {
|
|
7
|
-
//
|
|
8
|
-
const fullCommand =
|
|
7
|
+
// 加载常见 shell 初始化文件与 Node 版本管理器,使远程 PATH 与登录会话一致
|
|
8
|
+
const fullCommand = [
|
|
9
|
+
'[ -f /etc/profile ] && source /etc/profile',
|
|
10
|
+
'[ -f ~/.bash_profile ] && source ~/.bash_profile',
|
|
11
|
+
'[ -f ~/.bash_login ] && source ~/.bash_login',
|
|
12
|
+
'[ -f ~/.profile ] && source ~/.profile',
|
|
13
|
+
'[ -f ~/.bashrc ] && source ~/.bashrc',
|
|
14
|
+
'[ -n "$NVM_DIR" ] && [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"',
|
|
15
|
+
'[ -s "$HOME/.nvm/nvm.sh" ] && source "$HOME/.nvm/nvm.sh"',
|
|
16
|
+
'[ -s "$HOME/.fnm/env.sh" ] && source "$HOME/.fnm/env.sh"',
|
|
17
|
+
'[ -d "$HOME/.local/bin" ] && export PATH="$HOME/.local/bin:$PATH"',
|
|
18
|
+
'[ -d "$HOME/bin" ] && export PATH="$HOME/bin:$PATH"',
|
|
19
|
+
command,
|
|
20
|
+
].join('; ');
|
|
9
21
|
return new Promise((resolve, reject) => {
|
|
10
22
|
// @ts-ignore: ssh2-sftp-client types don't expose client but it exists at runtime
|
|
11
23
|
const client = (sftp as any).client;
|