仅对某些文件使用 ssh2-sftp-client (NodeJS) 的 uploaDir 过滤条件

Filter condition for uploaDir using ssh2-sftp-client (NodeJS) for only certain files

在我的 nodejs 代码中,我使用 ssh2-sftp-client (https://github.com/theophilusx/ssh2-sftp-client) 将一些文件传输到远程服务器:

我目录中的文件如下:

srcDir :

file1.py
file2.py
test.csv

我的示例代码如下:

   let SftpClient = require('ssh2-sftp-client');
   let sftp = new SftpClient();
   sftp.connect(connSettings)
         .then(() => {
          return sftp.uploadDir(srcDir,dst);   //need filter here
          }).then(rslt => {
                           ..
    }

代码将 srcDir(py 和 csv)中的所有文件上传到目标,但我只想将 python 文件复制到目标。我可以看到过滤器参数,但我无法找出实现它的表达式。

我不确定我尝试过的示例中的模式

/*.py/ 
/^(.*\.(?!(py)$))?[^.]*$/i 
/^[^.py]/

等但似乎没有帮助。

谢谢 [1]: https://github.com/theophilusx/ssh2-sftp-client

使用 6.0.0 版本的 ssh2-sftp-client