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

js-green-licenses

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-green-licenses - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

1

build/src/checker.d.ts

@@ -46,2 +46,3 @@ /// <reference types="node" />

private isGreenLicense;
private getPackageJson;
private checkLicenses;

@@ -48,0 +49,0 @@ private checkLicensesForDeps;

44

build/src/checker.js

@@ -183,3 +183,18 @@ "use strict";

}
async checkLicenses(packageName, versionSpec, ...parents) {
async getPackageJson(packageName, versionSpec, localDirectory) {
// If this has a relative URL, and is a local package, find the package json from the
// indicated directory
if (versionSpec.startsWith('file:') && localDirectory) {
const relativePath = versionSpec.slice('file:'.length);
const packageJsonPath = path.join(localDirectory, relativePath, 'package.json');
this.emit('package.json', packageJsonPath);
const contents = await fsReadFile(packageJsonPath, 'utf8');
return JSON.parse(contents);
}
return package_json_1.default(packageName, {
version: versionSpec,
fullMetadata: true,
});
}
async checkLicenses(packageName, versionSpec, localDirectory, ...parents) {
const spec = `${packageName}@${versionSpec}`;

@@ -194,7 +209,4 @@ if (this.failedPackages.has(spec))

try {
const json = await package_json_1.default(packageName, {
version: versionSpec,
fullMetadata: true,
});
await this.checkPackageJson(json, packageName, ...parents);
const json = await this.getPackageJson(packageName, versionSpec, localDirectory);
await this.checkPackageJson(json, packageName, localDirectory, ...parents);
}

@@ -211,3 +223,3 @@ catch (err) {

}
async checkLicensesForDeps(deps, ...parents) {
async checkLicensesForDeps(deps, localDirectory, ...parents) {
if (!deps)

@@ -217,6 +229,6 @@ return;

const depVersion = deps[pkg];
await this.checkLicenses(pkg, depVersion, ...parents);
await this.checkLicenses(pkg, depVersion, localDirectory, ...parents);
}
}
async checkPackageJson(json, packageName, ...parents) {
async checkPackageJson(json, packageName, localDirectory, ...parents) {
const pj = package_json_file_1.ensurePackageJson(json);

@@ -248,8 +260,8 @@ if (!packageName) {

}
await this.checkLicensesForDeps(pj.dependencies, ...parents, packageAndVersion);
await this.checkLicensesForDeps(pj.dependencies, localDirectory, ...parents, packageAndVersion);
if (this.opts.dev) {
await this.checkLicensesForDeps(pj.devDependencies, ...parents, packageAndVersion);
await this.checkLicensesForDeps(pj.devDependencies, localDirectory, ...parents, packageAndVersion);
}
}
async checkPackageJsonContent(content) {
async checkPackageJsonContent(content, localDirectory) {
// tslint:disable-next-line:no-any `JSON.parse()` returns any

@@ -259,3 +271,3 @@ let json = null;

json = JSON.parse(content);
await this.checkPackageJson(json, json.name);
await this.checkPackageJson(json, json.name, localDirectory);
}

@@ -319,3 +331,3 @@ catch (err) {

const content = await fsReadFile(pj, 'utf8');
await this.checkPackageJsonContent(content);
await this.checkPackageJsonContent(content, path.dirname(pj));
}

@@ -335,3 +347,3 @@ this.emit('end');

}
await this.checkLicenses(pkgArgs.name, pkgArgs.fetchSpec);
await this.checkLicenses(pkgArgs.name, pkgArgs.fetchSpec, null);
this.emit('end');

@@ -358,3 +370,3 @@ }

this.emit('package.json', pj.filePath);
await this.checkPackageJsonContent(pj.content);
await this.checkPackageJsonContent(pj.content, null);
}

@@ -361,0 +373,0 @@ this.emit('end');

@@ -7,2 +7,9 @@ # Changelog

## [1.1.0](https://www.github.com/google/js-green-licenses/compare/v1.0.0...v1.1.0) (2019-06-05)
### Features
* support local paths ([#101](https://www.github.com/google/js-green-licenses/issues/101)) ([6d08407](https://www.github.com/google/js-green-licenses/commit/6d08407))
## [1.0.0](https://www.github.com/google/js-green-licenses/compare/v0.5.0...v1.0.0) (2019-05-29)

@@ -9,0 +16,0 @@

{
"name": "js-green-licenses",
"version": "1.0.0",
"version": "1.1.0",
"description": "JavaScript package.json license checker",

@@ -70,5 +70,6 @@ "main": "build/src/checker.js",

"@types/tmp": "0.1.0",
"ava": "^1.0.0",
"ava": "^2.0.0",
"codecov": "^3.0.1",
"gts": "^1.0.0",
"inline-fixtures": "^1.1.0",
"make-dir": "^3.0.0",

@@ -80,4 +81,4 @@ "mock-fs": "^4.4.2",

"tmp": "0.1.0",
"typescript": "~3.4.0"
"typescript": "~3.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