@expo/downloader
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -6,15 +6,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_1 = __importDefault(require("fs")); | ||
const stream_1 = __importDefault(require("stream")); | ||
const util_1 = require("util"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const got_1 = __importDefault(require("got")); | ||
const pipeline = util_1.promisify(stream_1.default.pipeline); | ||
async function downloadFile(srcUrl, outputPath, timeout) { | ||
const res = await node_fetch_1.default(srcUrl, { timeout }); | ||
if (res.status !== 200) { | ||
throw new Error(`Failed to download the file, status code: ${res.status}`); | ||
try { | ||
await pipeline(got_1.default.stream(srcUrl, { timeout }), fs_extra_1.default.createWriteStream(outputPath)); | ||
} | ||
await pipeline(res.body, fs_1.default.createWriteStream(outputPath)); | ||
catch (err) { | ||
await fs_extra_1.default.remove(outputPath); | ||
throw new Error(`Failed to download the file: ${err === null || err === void 0 ? void 0 : err.message}\n${err === null || err === void 0 ? void 0 : err.stack}`); | ||
} | ||
} | ||
exports.default = downloadFile; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@expo/downloader", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "dist/index.js", | ||
@@ -18,9 +18,13 @@ "types": "dist/index.d.ts", | ||
"lint": "eslint 'src/**/*.ts'", | ||
"test": "yarn run jest" | ||
"test:unit": "echo \"no tests found\" || ./resources/jest --config jest.config.unit.js", | ||
"test:unit:watch": "./resources/jest --config jest.config.unit.js --watch", | ||
"test:integration": "./resources/jest --runInBand --config jest.config.integration.js", | ||
"test:integration:watch": "./resources/jest --runInBand --config jest.config.integration.js --watchAll" | ||
}, | ||
"dependencies": { | ||
"node-fetch": "^2.6.0" | ||
"fs-extra": "^9.0.0", | ||
"got": "^11.1.4" | ||
}, | ||
"devDependencies": { | ||
"@types/node-fetch": "^2.5.5", | ||
"@types/fs-extra": "^9.0.1", | ||
"@typescript-eslint/eslint-plugin": "^2.11.0", | ||
@@ -31,4 +35,6 @@ "@typescript-eslint/parser": "^2.11.0", | ||
"eslint-config-airbnb-typescript": "^6.3.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.19.1", | ||
"jest": "^24.9.0", | ||
"prettier": "^2.0.5", | ||
"ts-jest": "^24.2.0", | ||
@@ -35,0 +41,0 @@ "typescript": "^3.7.3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
276231
22
0
2
12
+ Addedfs-extra@^9.0.0
+ Addedgot@^11.1.4
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@szmarczak/http-timer@4.0.6(transitive)
+ Added@types/cacheable-request@6.0.3(transitive)
+ Added@types/http-cache-semantics@4.0.4(transitive)
+ Added@types/keyv@3.1.4(transitive)
+ Added@types/node@22.10.2(transitive)
+ Added@types/responselike@1.0.3(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedcacheable-lookup@5.0.4(transitive)
+ Addedcacheable-request@7.0.4(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddefer-to-connect@2.0.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedgot@11.8.6(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp2-wrapper@1.0.3(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmimic-response@1.0.13.1.0(transitive)
+ Addednormalize-url@6.1.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@2.1.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
+ Addedresponselike@2.0.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removednode-fetch@^2.6.0
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)