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.6.0-alpha.c8357d7f to 2.6.0

lib/__tests__/__fixtures__/packages/a-package/no-package-json/file.js.js

10

lib/__tests__/packages.test.js

@@ -30,2 +30,12 @@ 'use strict';

it('works for existing modules with .js on their name', function () {
expect(pkgs.resolveModuleFile(pkgDir, './no-package-json/file.js')).toBe('no-package-json/file.js.js');
});
it('works for non-existent modules', function () {
expect(pkgs.resolveModuleFile(pkgDir, './no-package-json/non-existent-module')).toBe('no-package-json/non-existent-module.js');
expect(pkgs.resolveModuleFile(pkgDir, './no-package-json/non-existent-module.js')).toBe('no-package-json/non-existent-module.js');
});
it('works for directories without package.json file', function () {

@@ -32,0 +42,0 @@ expect(pkgs.resolveModuleFile(pkgDir, 'no-package-json')).toBe('no-package-json/index.js');

17

lib/packages.js

@@ -143,4 +143,19 @@ 'use strict';

// Given module name is a file: do nothing
} else if (fullModulePath.endsWith('.js')) {
// Given module name is not a directory nor a file but ends with '.js'
// extension: see if corresponding '.js.js' file exists
moduleStats = safeStat(fullModulePath + '.js');
if (moduleStats.isFile()) {
// Given module name has a corresponding '.js.js' file: add '.js'
// extension
fullModulePath += '.js';
} else {
// Given module name has no corresponding '.js.js' file: do nothing
// and assume that the '.js' in the module name is just the
// extension of the file and doesn't belong to its name.
}
} else {
// Given module name is not a directory nor a file: add '.js' extension
// Given module name is not a directory nor a file and doesn't end with
// '.js' extension: add '.js' extension
fullModulePath += '.js';

@@ -147,0 +162,0 @@ }

2

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

@@ -5,0 +5,0 @@ "scripts": {

@@ -33,2 +33,24 @@ import path from 'path';

it('works for existing modules with .js on their name', () => {
expect(
pkgs.resolveModuleFile(pkgDir, './no-package-json/file.js')
).toBe('no-package-json/file.js.js');
});
it('works for non-existent modules', () => {
expect(
pkgs.resolveModuleFile(
pkgDir,
'./no-package-json/non-existent-module'
)
).toBe('no-package-json/non-existent-module.js');
expect(
pkgs.resolveModuleFile(
pkgDir,
'./no-package-json/non-existent-module.js'
)
).toBe('no-package-json/non-existent-module.js');
});
it('works for directories without package.json file', () => {

@@ -35,0 +57,0 @@ expect(pkgs.resolveModuleFile(pkgDir, 'no-package-json')).toBe(

@@ -94,3 +94,3 @@ import fs from 'fs';

);
const moduleStats = safeStat(fullModulePath);
let moduleStats = safeStat(fullModulePath);

@@ -125,4 +125,19 @@ if (moduleStats.isDirectory()) {

// Given module name is a file: do nothing
} else if (fullModulePath.endsWith('.js')) {
// Given module name is not a directory nor a file but ends with '.js'
// extension: see if corresponding '.js.js' file exists
moduleStats = safeStat(`${fullModulePath}.js`);
if (moduleStats.isFile()) {
// Given module name has a corresponding '.js.js' file: add '.js'
// extension
fullModulePath += '.js';
} else {
// Given module name has no corresponding '.js.js' file: do nothing
// and assume that the '.js' in the module name is just the
// extension of the file and doesn't belong to its name.
}
} else {
// Given module name is not a directory nor a file: add '.js' extension
// Given module name is not a directory nor a file and doesn't end with
// '.js' extension: add '.js' extension
fullModulePath += '.js';

@@ -129,0 +144,0 @@ }

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