🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

latest-lib

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

latest-lib - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+8
-5
index.js

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

got(`https://api.cdnjs.com/libraries?search=${name}&fields=assets`, {json: true})
got(`https://api.cdnjs.com/libraries?search=${name}&fields=version,assets`, {json: true})
.then(res => {

@@ -18,10 +18,13 @@ if (res.body.results.length > 0) {

const library = res.body.results[0];
const versionAssets = library.assets.filter(files => {
return files.version === library.version;
});
// https://cdnjs.cloudflare.com/ajax/libs/[library]/[version]/[files]
const rootDirectory = library.latest.substring(
0,
(library.latest.indexOf(library.assets[0].version) +
library.assets[0].version.length)
(library.latest.indexOf(library.version) +
library.version.length)
).concat('/');
// Return only the latest version
let files = library.assets[0].files.map(item => urlResolve(rootDirectory, item));
let files = versionAssets[0].files.map(item => urlResolve(rootDirectory, item));

@@ -42,3 +45,3 @@ if (opts && opts.only) {

name: library.name,
version: library.assets[0].version,
version: versionAssets[0].version,
files

@@ -45,0 +48,0 @@ });

{
"name": "latest-lib",
"version": "0.1.1",
"version": "0.1.2",
"description": "Get the latest version of a CSS or JavaScript library hosted on CDNJS",

@@ -5,0 +5,0 @@ "main": "index.js",