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

liferay-npm-build-tools-common

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liferay-npm-build-tools-common - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

18

lib/__tests__/namespace.test.js

@@ -74,2 +74,10 @@ 'use strict';

it('addNamespace leaves local module names untouched', function () {
expect(ns.addNamespace('./path/to/module', { name: 'a-package' })).toBe('./path/to/module');
expect(ns.addNamespace('../path/to/module', { name: 'a-package' })).toBe('../path/to/module');
expect(ns.addNamespace('a-package/path/to/module', { name: 'a-package' })).toBe('a-package/path/to/module');
});
it('removeNamespace works', function () {

@@ -152,2 +160,12 @@ // Package alone

it('addNamespace leaves local module names untouched', function () {
expect(ns.addNamespace('./path/to/module', { name: '@scope/a-package' })).toBe('./path/to/module');
expect(ns.addNamespace('../path/to/module', { name: '@scope/a-package' })).toBe('../path/to/module');
expect(ns.addNamespace('@scope/a-package/path/to/module', {
name: '@scope/a-package'
})).toBe('@scope/a-package/path/to/module');
});
it('removeNamespace works', function () {

@@ -154,0 +172,0 @@ // Scope alone

14

lib/namespace.js

@@ -11,2 +11,9 @@ 'use strict';

exports.makeNamespace = makeNamespace;
var _modules = require('./modules');
var mod = _interopRequireWildcard(_modules);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/**

@@ -24,2 +31,3 @@ * Test if a module name is namespaced according to any root package.

* name is already namespaced with a different root package, an Error is thrown.
* If the module is local it is left untouched.
* @param {String} moduleName a module name

@@ -52,3 +60,7 @@ * @param {String} name name of root package

if (moduleName.startsWith('@')) {
if (mod.isLocalModule(moduleName)) {
return moduleName;
} else if (moduleName.startsWith(name + '/') || moduleName === name) {
return moduleName;
} else if (moduleName.startsWith('@')) {
return moduleName.replace('@', '@' + namespace);

@@ -55,0 +67,0 @@ } else {

@@ -18,2 +18,6 @@ 'use strict';

var _readJsonSync2 = require('read-json-sync');
var _readJsonSync3 = _interopRequireDefault(_readJsonSync2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -49,3 +53,13 @@

try {
_fs2.default.statSync(_path2.default.join(dir, 'package.json'));
var pkgJsonPath = _path2.default.join(dir, 'package.json');
_fs2.default.statSync(pkgJsonPath);
var _readJsonSync = (0, _readJsonSync3.default)(pkgJsonPath),
version = _readJsonSync.version;
if (version === undefined) {
throw new Error('No valid version field found');
}
found = true;

@@ -52,0 +66,0 @@ } catch (err) {

5

package.json
{
"name": "liferay-npm-build-tools-common",
"version": "2.1.0",
"version": "2.1.1",
"description": "Utility library for Liferay NPM Build Tools.",

@@ -12,3 +12,6 @@ "scripts": {

"babel-preset-es2015": "^6.24.1"
},
"dependencies": {
"read-json-sync": "^2.0.0"
}
}

@@ -78,2 +78,16 @@ import * as ns from '../namespace';

it('addNamespace leaves local module names untouched', () => {
expect(ns.addNamespace('./path/to/module', {name: 'a-package'})).toBe(
'./path/to/module'
);
expect(
ns.addNamespace('../path/to/module', {name: 'a-package'})
).toBe('../path/to/module');
expect(
ns.addNamespace('a-package/path/to/module', {name: 'a-package'})
).toBe('a-package/path/to/module');
});
it('removeNamespace works', () => {

@@ -186,2 +200,18 @@ // Package alone

it('addNamespace leaves local module names untouched', () => {
expect(
ns.addNamespace('./path/to/module', {name: '@scope/a-package'})
).toBe('./path/to/module');
expect(
ns.addNamespace('../path/to/module', {name: '@scope/a-package'})
).toBe('../path/to/module');
expect(
ns.addNamespace('@scope/a-package/path/to/module', {
name: '@scope/a-package',
})
).toBe('@scope/a-package/path/to/module');
});
it('removeNamespace works', () => {

@@ -188,0 +218,0 @@ // Scope alone

@@ -0,1 +1,3 @@

import * as mod from './modules';
/**

@@ -13,2 +15,3 @@ * Test if a module name is namespaced according to any root package.

* name is already namespaced with a different root package, an Error is thrown.
* If the module is local it is left untouched.
* @param {String} moduleName a module name

@@ -42,3 +45,7 @@ * @param {String} name name of root package

if (moduleName.startsWith('@')) {
if (mod.isLocalModule(moduleName)) {
return moduleName;
} else if (moduleName.startsWith(`${name}/`) || moduleName === name) {
return moduleName;
} else if (moduleName.startsWith('@')) {
return moduleName.replace('@', `@${namespace}`);

@@ -45,0 +52,0 @@ } else {

import fs from 'fs';
import path from 'path';
import readJsonSync from 'read-json-sync';

@@ -32,3 +33,12 @@ let packageDirCache = {};

try {
fs.statSync(path.join(dir, 'package.json'));
const pkgJsonPath = path.join(dir, 'package.json');
fs.statSync(pkgJsonPath);
const {version} = readJsonSync(pkgJsonPath);
if (version === undefined) {
throw new Error('No valid version field found');
}
found = true;

@@ -35,0 +45,0 @@ } catch (err) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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