New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

npminstall

Package Overview
Dependencies
Maintainers
2
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npminstall - npm Package Compare versions

Comparing version 2.2.4 to 2.3.0

14

bin/install.js

@@ -27,2 +27,4 @@ #!/usr/bin/env node

'custom-china-mirror-url',
// {"http://a.com":"http://b.com"}
'tarball-url-mapping',
],

@@ -184,2 +186,14 @@ boolean: [

config.ignoreScripts = argv['ignore-scripts'] || getIgnoreScripts();
if (argv['tarball-url-mapping']) {
const tarballUrlMapping = JSON.parse(argv['tarball-url-mapping']);
config.formatNpmTarbalUrl = function formatNpmTarbalUrl(url) {
for (const fromUrl in tarballUrlMapping) {
const toUrl = tarballUrlMapping[fromUrl];
url = url.replace(fromUrl, toUrl);
}
return url;
};
}
// -g install to npm's global prefix

@@ -186,0 +200,0 @@ if (argv.global) {

2.3.0 / 2016-09-19
==================
* feat: support --tarball-url-mapping=json-string (#127)
2.2.4 / 2016-09-18

@@ -3,0 +8,0 @@ ==================

24

lib/download/npm.js

@@ -14,2 +14,3 @@ 'use strict';

const semver = require('semver');
const urlresolve = require('url').resolve;
const get = require('../get');

@@ -260,9 +261,19 @@ const utils = require('../utils');

function* getTarballStream(pkg, options) {
let tarballUrl = pkg.dist.tarball;
let formatRedirectUrl;
if (options.formatNpmTarbalUrl) {
tarballUrl = options.formatNpmTarbalUrl(tarballUrl);
formatRedirectUrl = function(from, to) {
return options.formatNpmTarbalUrl(urlresolve(from, to));
};
}
if (!options.cacheDir || utils.isSudo()) {
// sudo don't touch the cacheDir
// production mode
debug('[%s@%s] GET streaming %j', pkg.name, pkg.version, pkg.dist.tarball);
const result = yield get(pkg.dist.tarball, {
debug('[%s@%s] GET streaming %j', pkg.name, pkg.version, tarballUrl);
const result = yield get(tarballUrl, {
timeout: options.timeout,
followRedirect: true,
formatRedirectUrl,
streaming: true,

@@ -273,3 +284,3 @@ }, options);

destroy(result.res);
throw new Error(`Download ${pkg.dist.tarball} status: ${result.status} error, should be 200`);
throw new Error(`Download ${tarballUrl} status: ${result.status} error, should be 200`);
}

@@ -297,5 +308,6 @@

const tmpFile = path.join(parentDir, `${pkg.version}-tmp.tgz`);
const result = yield get(pkg.dist.tarball, {
const result = yield get(tarballUrl, {
timeout: options.timeout,
followRedirect: true,
formatRedirectUrl,
writeStream: fs.createWriteStream(tmpFile),

@@ -305,3 +317,3 @@ }, options);

if (result.status !== 200) {
throw new Error(`Download ${pkg.dist.tarball} status: ${result.status} error, should be 200`);
throw new Error(`Download ${tarballUrl} status: ${result.status} error, should be 200`);
}

@@ -314,3 +326,3 @@ if (yield fs.exists(tarballFile)) {

debug('[%s@%s] saved %s %s => %s',
pkg.name, pkg.version, bytes(stat.size), pkg.dist.tarball, tarballFile);
pkg.name, pkg.version, bytes(stat.size), tarballUrl, tarballFile);
options.totalTarballSize += stat.size;

@@ -317,0 +329,0 @@ }

{
"name": "npminstall",
"version": "2.2.4",
"version": "2.3.0",
"description": "Let npm install fast and easy",

@@ -47,3 +47,3 @@ "main": "lib/index.js",

"tar": "^2.2.1",
"urllib": "^2.10.0",
"urllib": "^2.14.0",
"utility": "^1.8.0",

@@ -50,0 +50,0 @@ "uuid": "^2.0.2"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc