sftp-zip-deploy 0.2.1 → 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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # sftp-zip-deploy
2
2
 
3
+ [![Build Status](https://github.com/vitaly-t/sftp-zip-deploy/actions/workflows/ci.yml/badge.svg)](https://github.com/vitaly-t/sftp-zip-deploy/actions/workflows/ci.yml)
3
4
  [![Node Version](https://img.shields.io/badge/nodejs-%2026-green.svg?logo=node.js&style=flat)](https://nodejs.org)
4
5
 
5
6
  Fast and efficient way to auto-deploy your project to a server:
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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Client as SSH2Client, ConnectConfig } from 'ssh2';
1
+ import { Client as SSH2Client } from 'ssh2';
2
+ import type { ConnectConfig } from 'ssh2';
2
3
  export declare function connectSSH2Client(client: SSH2Client, cn: ConnectConfig): Promise<SSH2Client>;
3
4
  export declare function execSSH2Command(client: SSH2Client, cmd: string, output: (err?: Buffer, std?: Buffer) => void): Promise<void>;
4
5
  /**
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,12 +1,14 @@
1
1
  {
2
2
  "name": "sftp-zip-deploy",
3
- "version": "0.2.1",
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",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "build": "tsc -p src"
9
+ "build": "tsc -p src",
10
+ "test": "node --test test/utils.test.ts",
11
+ "test:coverage": "node --experimental-test-coverage --test test/utils.test.ts"
10
12
  },
11
13
  "files": [
12
14
  "dist"