Skip to content

Commit b811a38

Browse files
authored
Refine dependencies (#33)
* Add package-lock=false in .npmrc * Minimal Node.js version in v12 * Upgrade tap * Drop mkdirp dependency * Upgrade tar * Replace request with make-fetch-happen * Upgrade log-update * Replace pump with pipeline * refine CI
1 parent 6b73e0f commit b811a38

File tree

6 files changed

+32
-33
lines changed

6 files changed

+32
-33
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
build:
1717
runs-on: "ubuntu-latest"
1818
steps:
19-
- uses: "actions/checkout@v2"
19+
- uses: "actions/checkout@v3"
2020

21-
- uses: "actions/setup-node@v2"
21+
- uses: "actions/setup-node@v3"
2222
with:
2323
node-version: "14.x"
2424

25-
- run: npm install
25+
- run: npm install --ignore-scripts --no-fund
2626

27-
- run: node test/index.js
27+
- run: npm test -- --no-check-coverage --timeout=60

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

cancelable-pump/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const pump = require('pump');
3+
const {pipeline: pump} = require('stream');
44

55
const cancel = new Error('Canceled.');
66

dl-tar/index.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
'use strict';
22

3-
const {inspect, promisify} = require('util');
3+
const {inspect} = require('util');
44
const {resolve} = require('path');
55
const {Transform} = require('stream');
6+
const {promises: fs} = require('fs');
67

78
const cancelablePump = require('../cancelable-pump/index.js');
89
const {Unpack} = require('tar');
910
const isPlainObj = require('is-plain-obj');
10-
const request = require('request');
11-
const mkdirp = require('mkdirp');
11+
const fetch = require('make-fetch-happen');
1212
const Observable = require('zen-observable');
1313

14-
const promisifiedMkdirp = promisify(mkdirp);
15-
1614
class InternalUnpack extends Unpack {
1715
constructor(options) {
1816
super({
@@ -173,7 +171,7 @@ module.exports = function dlTar(...args) {
173171
(async () => {
174172
try {
175173
if (absoluteDest !== cwd) {
176-
await promisifiedMkdirp(absoluteDest);
174+
await fs.mkdir(absoluteDest, {recursive: true});
177175
}
178176

179177
if (ended) {
@@ -186,21 +184,24 @@ module.exports = function dlTar(...args) {
186184
observer
187185
});
188186

189-
const pipe = [
190-
request({url, ...options, encoding: null})
191-
.on('response', function(response) {
192-
if (response.statusCode < 200 || 299 < response.statusCode) {
193-
this.emit('error', new Error(`${response.statusCode} ${response.statusMessage}`));
194-
return;
195-
}
187+
const {baseUrl, headers} = options;
188+
const {href} = new URL(url, baseUrl);
196189

197-
if (typeof response.headers['content-length'] === 'string') {
198-
response.headers['content-length'] = Number(response.headers['content-length']);
199-
}
190+
const res = await fetch(href, {headers}).then(response => {
200191

201-
unpackStream.url = response.request.uri.href;
202-
unpackStream.responseHeaders = response.headers;
203-
}),
192+
if (response.ok !== true) {
193+
throw new Error(`${response.status} ${response.statusText}`);
194+
}
195+
196+
unpackStream.url = response.url;
197+
unpackStream.responseHeaders = response.headers;
198+
199+
return response;
200+
201+
});
202+
203+
const pipe = [
204+
res.body,
204205
new Transform({
205206
transform(chunk, encoding, cb) {
206207
unpackStream.responseBytes += chunk.length;

install-purescript/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ const fs = require('fs');
44
const {execFile} = require('child_process');
55
const path = require('path');
66
const {inspect, promisify} = require('util');
7-
const {Writable} = require('stream');
7+
const {pipeline: pump} = require('stream');
88

99
const arch = require('arch');
1010
const {create, Unpack} = require('tar');
1111
const cacache = require('cacache');
1212
const isPlainObj = require('is-plain-obj');
1313
const Observable = require('zen-observable');
14-
const pump = require('pump');
1514
const envPaths = require('env-paths');
1615

1716
const downloadOrBuildPurescript = require('../download-or-build-purescript/index.js');

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"install-purescript": "index.js"
77
},
88
"engines": {
9-
"node": ">=8.3.0"
9+
"node": ">=12"
1010
},
1111
"dependencies": {
1212
"arch": "^2.1.1",
@@ -18,21 +18,19 @@
1818
"filesize": "^4.1.2",
1919
"is-plain-obj": "^2.0.0",
2020
"log-symbols": "^3.0.0",
21-
"log-update": "^3.2.0",
21+
"log-update": "^4.0.0",
22+
"make-fetch-happen": "^10.0.0",
2223
"minimist": "^1.2.0",
23-
"mkdirp": "^0.5.1",
2424
"ms": "^2.1.2",
2525
"once": "^1.4.0",
26-
"pump": "^3.0.0",
27-
"request": "^2.88.0",
2826
"rimraf": "^2.6.3",
2927
"semver": "^7.3.7",
30-
"tar": "^4.4.6",
28+
"tar": "^6.1.11",
3129
"which": "^1.3.1",
3230
"zen-observable": "^0.8.14"
3331
},
3432
"devDependencies": {
35-
"tap": "^14.2.3"
33+
"tap": "^16.2.0"
3634
},
3735
"scripts": {
3836
"test": "tap"

0 commit comments

Comments
 (0)