Skip to content

Commit

Permalink
fix the filter issue of upload directory
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyucode committed Aug 16, 2022
1 parent fb73a95 commit 948cf43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class Deployer {
} else {
console.log(`${this.options.dryRun ? 'Dry-run: ' : ''}uploading dir ${dirent.name}`);
if (!this.options.dryRun) {
this.promises.push(this.sftp.uploadDir(
await this.sftp.uploadDir(
path.join(localPath, dirent.name),
remoteFile,
{ filter: (path, isDirectory) => this.isIgnoreFile(path) }
));
{ filter: (path, isDirectory) => !this.isIgnoreFile(path) }
);
}
}
} else {
Expand Down Expand Up @@ -89,7 +89,6 @@ class Deployer {
} else {
if (remoteExists) {
if (remoteExists === '-') {
console.log(`checking modified timestamp of ${remoteFile}`);
const localStats = await lstat(localFile);
const remoteStats = await this.sftp.stat(remoteFile);
if (remoteStats.modifyTime < localStats.mtimeMs) {
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
new Deployer({
host: '192.168.0.99',
privateKey: fs.readFileSync('./id_rsa'),
localDir: './node_modules',
remoteDir: '/root/test/blablabla'
}, { exclude: ['*!ssh2-sftp-client'], dryRun: false, forceUpload: true })
localDir: './',
remoteDir: '/root/test/'
}, { exclude: ['node_modules'], dryRun: false })
.sync();

0 comments on commit 948cf43

Please sign in to comment.