sftp-zip-deploy 0.2.2 → 0.2.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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import SftpClient from 'ssh2-sftp-client';
2
2
  import { Client as SSH2Client } from 'ssh2';
3
3
  import { connectSSH2Client, execSSH2Command, fixWindowsPath, zipFiles } from './utils.js';
4
- import { globSync } from 'glob';
4
+ import { glob } from 'glob';
5
5
  import path from 'node:path';
6
6
  export { default as ConnectOptions } from 'ssh2-sftp-client';
7
7
  /**
@@ -24,8 +24,8 @@ export async function zipAndDeploy(cfg) {
24
24
  if (before) {
25
25
  await execSSH2Command(ssh2Client, before, (err, std) => cfg.onCmdOutput?.(before, err, std));
26
26
  }
27
- let files = globSync('**/{*.*,*}', { cwd: cfg.srcDir, nodir: true, dot: true })
28
- .map(f => fixWindowsPath(f));
27
+ let files = await glob('**/{*.*,*}', { cwd: cfg.srcDir, nodir: true, dot: true })
28
+ .then(a => a.map(f => fixWindowsPath(f)));
29
29
  if (typeof cfg.onFilter === 'function') {
30
30
  files = files.filter(cfg.onFilter);
31
31
  }
package/dist/utils.js CHANGED
@@ -17,13 +17,19 @@ export function execSSH2Command(client, cmd, output) {
17
17
  return reject(err);
18
18
  }
19
19
  stream.once('close', (code) => {
20
- if (code) {
21
- reject(new Error(`Command "${cmd}" exited with code ${code}`));
22
- }
23
- else {
24
- resolve();
20
+ switch (code) {
21
+ case 0:
22
+ resolve();
23
+ break;
24
+ case null:
25
+ case undefined:
26
+ reject(new Error(`Command "${cmd}" terminated abnormally`));
27
+ break;
28
+ default:
29
+ reject(new Error(`Command "${cmd}" exited with code ${code}`));
25
30
  }
26
31
  });
32
+ stream.once('error', (err) => reject(err));
27
33
  stream.on('data', (chunk) => output(undefined, chunk));
28
34
  stream.stderr.on('data', (chunk) => output(chunk, undefined));
29
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sftp-zip-deploy",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Zip and deploy folder over SFTP",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",