Socket
Socket
Sign inDemoInstall

snyk-paket-parser

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snyk-paket-parser - npm Package Compare versions

Comparing version 1.4.3 to 1.5.0

51

dist/dependencies-parser.js

@@ -16,23 +16,40 @@ "use strict";

function parseNuget(line) {
var commentRegex = new RegExp("(?:" + COMMENTS[0] + "|" + COMMENTS[1] + ").+");
var nameVersionOptionsRegex = new RegExp(/(\S+)\s*([^:\n]*)(:.*)?/);
var versionFirstOptionRegex = new RegExp(/\s(?=[^ ]*$)/);
var _a = tslib_1.__read(line
.replace(NUGET, '') // Remove 'nuget' string
.replace(commentRegex, '') // Remove comments from line end
.trim()
.match(nameVersionOptionsRegex), 4), name = _a[1], versionRangeAndFirstOption = _a[2], restOptions = _a[3]; // Split into groups for further parsing
// nuget dependency result object to be returned
var result = {
name: '',
source: NUGET,
name: name,
versionRange: versionRangeAndFirstOption,
options: {},
source: 'nuget',
versionRange: '',
};
// Get position of first option.
var firstOptionMatch = /\s*[^\s]+\s*:/.exec(line);
var dependencyString = line;
// let optionsString = '';
if (firstOptionMatch) {
// Split line by position of first option.
dependencyString = line.substr(0, firstOptionMatch.index);
// optionsString = line.substr(firstOptionMatch.index).trim();
if (restOptions) {
// tslint:disable-next-line:prefer-const
var _b = tslib_1.__read(versionRangeAndFirstOption.split(versionFirstOptionRegex), 2), versionRange = _b[0], firstOptionName = _b[1];
result.versionRange = versionRange;
// If version is missing it will treat first option as version
if (!firstOptionName) {
result.versionRange = '';
firstOptionName = versionRange;
}
result.options = ("" + firstOptionName + restOptions)
.split(/\s*,\s*/) // Split by comma if there is couple possibilities for option (e.g. framework >= net40, net45)
.reverse()
.reduce(function (optionsMap, option, index, array) {
if (option.includes(':')) {
var _a = tslib_1.__read(option.split(/:\s*/), 2), optionKey = _a[0], value = _a[1];
optionsMap[optionKey] = value;
}
else {
array[index + 1] = array[index + 1] + ", " + option;
}
return optionsMap;
}, {});
}
dependencyString = dependencyString.replace(NUGET, '').trim();
// Split by space between words. First chunk will be name of the dependency and all rest - version.
var dependencyStringParts = dependencyString.split(/\s+/);
result.name = dependencyStringParts[0];
result.versionRange = dependencyStringParts.splice(1).join(' ');
// TODO: parse options
return result;

@@ -39,0 +56,0 @@ }

@@ -6,5 +6,4 @@ {

"scripts": {
"test": "node ./test-runner.js",
"test": "jest",
"test-jest": "jest",
"test-node4": "npm build && node ./test/node4/index.js",
"lint": "tslint -p tsconfig.json",

@@ -23,3 +22,3 @@ "build": "tsc",

"engines": {
"node": ">=4"
"node": ">=6"
},

@@ -35,3 +34,3 @@ "files": [

"devDependencies": {
"@types/node": "^4.0.47",
"@types/node": "^6.14.3",
"ts-node": "7.0.0",

@@ -44,3 +43,3 @@ "tslint": "5.11.0",

},
"version": "1.4.3"
"version": "1.5.0"
}

Sorry, the diff of this file is not supported yet

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