@firestartr/cli 1.30.0 → 1.32.0

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.
@@ -5,9 +5,12 @@
5
5
  // ctors). so we utilize `spawnSync` to spawn this program as a child process.
6
6
  // alternatively we could have use `curl` but this is more portable.
7
7
 
8
- const { http, https } = require('follow-redirects');
9
- const { parse } = require('url');
10
- const fs = require('fs');
8
+ import followRedirects from 'follow-redirects';
9
+ import { parse } from 'node:url';
10
+ import { lstatSync, createReadStream } from 'node:fs';
11
+ import process from 'node:process'
12
+
13
+ const { http, https } = followRedirects;
11
14
 
12
15
  const url = process.argv[2];
13
16
  if (!url) {
@@ -16,8 +19,8 @@ if (!url) {
16
19
  }
17
20
 
18
21
  try {
19
- if (fs.lstatSync(url).isFile()) {
20
- fs.createReadStream(url).pipe(process.stdout);
22
+ if (lstatSync(url).isFile()) {
23
+ createReadStream(url).pipe(process.stdout);
21
24
  }
22
25
  } catch (err) {
23
26
  const purl = parse(url);
@@ -25,16 +28,16 @@ try {
25
28
  if (!purl.protocol) {
26
29
  throw new Error(`unable to determine protocol from url: ${url}`);
27
30
  }
28
-
31
+
29
32
  const client = getHttpClient(purl.protocol);
30
33
  const get = client.get(url, response => {
31
34
  if (response.statusCode !== 200) {
32
35
  throw new Error(`${response.statusCode} response from http get: ${response.statusMessage}`);
33
36
  }
34
-
37
+
35
38
  response.on('data', chunk => process.stdout.write(chunk));
36
39
  });
37
-
40
+
38
41
  get.once('error', err => {
39
42
  throw new Error(`http error: ${err.message}`);
40
43
  });