liferay-npm-build-tools-common
Advanced tools
Comparing version 2.6.0-alpha.c8357d7f to 2.6.0
@@ -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'); |
@@ -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 @@ } |
{ | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
155579
82
2408
1