Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-node-support

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-node-support - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

lib/loader/octokit-wrapper.js

4

lib/deps.js

@@ -34,3 +34,3 @@ 'use strict';

if (dep.root === dep) {
if (dep.isProjectRoot) {
// root node is not a dep, really

@@ -45,3 +45,3 @@ continue;

if (!options.deep && ![...dep.edgesIn].some(({ from }) => from === arborist.idealTree)) {
if (!options.deep && ![...dep.edgesIn].some(({ from }) => from.isProjectRoot)) {
continue;

@@ -48,0 +48,0 @@ }

'use strict';
const GitUrlParse = require('git-url-parse');
const Wreck = require('@hapi/wreck');
const Logger = require('../logger');
const OctokitWrapper = require('./octokit-wrapper');
const Utils = require('../utils');

@@ -33,3 +33,3 @@

},
loadFile: async (filename, options) => {
loadFile: async (filename, options = {}) => {

@@ -40,24 +40,38 @@ if (parsedRepository.source !== 'github.com') {

const url = `https://raw.githubusercontent.com/${parsedRepository.full_name}/HEAD/${filename}`;
Logger.log(['loader'], 'Loading: %s', url);
const resource = `${parsedRepository.full_name}:${filename}@HEAD`;
Logger.log(['loader'], 'Loading: %s', resource);
if (options === undefined && internals.cache.has(url)) {
Logger.log(['loader'], 'From cache: %s', url);
return internals.cache.get(url);
}
const octokit = OctokitWrapper.create();
try {
const { payload } = await Wreck.get(url, options);
if (options === undefined) {
internals.cache.set(url, payload);
let result;
if (internals.cache.has(resource)) {
Logger.log(['loader'], 'From cache: %s', resource);
result = internals.cache.get(resource);
}
else {
result = await octokit.repos.getContent({
owner: parsedRepository.owner,
repo: parsedRepository.name,
path: filename
});
}
Logger.log(['loader'], 'Loaded: %s', url);
return payload;
internals.cache.set(resource, result);
Logger.log(['loader'], 'Loaded: %s', resource);
const content = Buffer.from(result.data.content, 'base64');
if (options.json) {
return JSON.parse(content.toString());
}
return content;
}
catch (err) {
if (err.data && err.data.res.statusCode === 404) {
Logger.log(['loader'], 'Not found: %s', url);
if (err.status === 404) {
Logger.log(['loader'], 'Not found: %s', resource);
const error = new Error(`${repository} does not contain a ${filename}`);

@@ -68,3 +82,3 @@ error.code = 'ENOENT';

Logger.error(['loader'], 'Failed to load: %s', url);
Logger.error(['loader'], 'Failed to load: %s', resource);
throw err;

@@ -71,0 +85,0 @@ }

@@ -48,3 +48,3 @@ 'use strict';

const packageJson = await loadFile('package.json', { json: 'force' });
const packageJson = await loadFile('package.json', { json: true });

@@ -51,0 +51,0 @@ const meta = {

{
"name": "detect-node-support",
"version": "1.4.2",
"version": "1.5.0",
"description": "List the Node.js versions supported by the package/repository",

@@ -35,7 +35,8 @@ "bin": {

"nock": "^13.0.0",
"sinon": "^9.0.0"
"sinon": "^10.0.0"
},
"dependencies": {
"@hapi/wreck": "^17.0.0",
"@npmcli/arborist": "^2.0.0",
"@npmcli/arborist": "^2.1.0",
"@octokit/plugin-throttling": "^3.2.2",
"@octokit/rest": "^18.0.0",
"@pkgjs/nv": "0.1.0",

@@ -42,0 +43,0 @@ "debug": "^4.1.1",

@@ -7,2 +7,6 @@ # detect-node-support

## Setup
No setup is required, however if you do not have a `GH_TOKEN` environment limit, you will likely hit a request rate limit on Github API, which may result in very long wait times for retries.
## Usage (command line)

@@ -9,0 +13,0 @@

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