liferay-npm-build-tools-common
Advanced tools
Comparing version 1.2.2 to 1.2.3
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -24,7 +24,7 @@ exports.getPackageJsonPath = getPackageJsonPath; | ||
* @param {String} modulePath the relative or absolute path to a JS module file | ||
* @return {String} the full path to the package.json file (with native path | ||
* @return {String} the full path to the package.json file (with native path | ||
* separators) | ||
*/ | ||
function getPackageJsonPath(modulePath) { | ||
return _path2.default.join(getPackageDir(modulePath), 'package.json'); | ||
return _path2.default.join(getPackageDir(modulePath), 'package.json'); | ||
} | ||
@@ -35,33 +35,33 @@ | ||
* @param {String} modulePath the relative or absolute path to a JS module file | ||
* @return {String} the full path to the package directory (with native path | ||
* @return {String} the full path to the package directory (with native path | ||
* separators) | ||
*/ | ||
function getPackageDir(modulePath) { | ||
var absModulePath = _path2.default.resolve(modulePath); | ||
var dir = packageDirCache[absModulePath]; | ||
var absModulePath = _path2.default.resolve(modulePath); | ||
var dir = packageDirCache[absModulePath]; | ||
if (!dir) { | ||
dir = absModulePath; | ||
var found = false; | ||
if (!dir) { | ||
dir = absModulePath; | ||
var found = false; | ||
while (!found) { | ||
try { | ||
_fs2.default.statSync(_path2.default.join(dir, 'package.json')); | ||
found = true; | ||
} catch (err) { | ||
var dirname = _path2.default.dirname(dir); | ||
while (!found) { | ||
try { | ||
_fs2.default.statSync(_path2.default.join(dir, 'package.json')); | ||
found = true; | ||
} catch (err) { | ||
var dirname = _path2.default.dirname(dir); | ||
if (dirname == dir) { | ||
throw new Error('Cannot find package.json for file: ' + modulePath); | ||
} | ||
if (dirname == dir) { | ||
throw new Error('Cannot find package.json for file: ' + modulePath); | ||
} | ||
dir = dirname; | ||
} | ||
} | ||
dir = dirname; | ||
} | ||
} | ||
packageDirCache[absModulePath] = dir; | ||
} | ||
packageDirCache[absModulePath] = dir; | ||
} | ||
return dir; | ||
return dir; | ||
} | ||
//# sourceMappingURL=packages.js.map |
{ | ||
"name": "liferay-npm-build-tools-common", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Utility library for Liferay NPM Build Tools.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -9,7 +9,7 @@ import fs from 'fs'; | ||
* @param {String} modulePath the relative or absolute path to a JS module file | ||
* @return {String} the full path to the package.json file (with native path | ||
* @return {String} the full path to the package.json file (with native path | ||
* separators) | ||
*/ | ||
export function getPackageJsonPath(modulePath) { | ||
return path.join(getPackageDir(modulePath), 'package.json'); | ||
return path.join(getPackageDir(modulePath), 'package.json'); | ||
} | ||
@@ -20,32 +20,34 @@ | ||
* @param {String} modulePath the relative or absolute path to a JS module file | ||
* @return {String} the full path to the package directory (with native path | ||
* @return {String} the full path to the package directory (with native path | ||
* separators) | ||
*/ | ||
export function getPackageDir(modulePath) { | ||
let absModulePath = path.resolve(modulePath); | ||
let dir = packageDirCache[absModulePath]; | ||
let absModulePath = path.resolve(modulePath); | ||
let dir = packageDirCache[absModulePath]; | ||
if (!dir) { | ||
dir = absModulePath; | ||
let found = false; | ||
if (!dir) { | ||
dir = absModulePath; | ||
let found = false; | ||
while (!found) { | ||
try { | ||
fs.statSync(path.join(dir, 'package.json')); | ||
found = true; | ||
} catch (err) { | ||
const dirname = path.dirname(dir); | ||
while (!found) { | ||
try { | ||
fs.statSync(path.join(dir, 'package.json')); | ||
found = true; | ||
} catch (err) { | ||
const dirname = path.dirname(dir); | ||
if (dirname == dir) { | ||
throw new Error('Cannot find package.json for file: ' + modulePath); | ||
} | ||
if (dirname == dir) { | ||
throw new Error( | ||
'Cannot find package.json for file: ' + modulePath | ||
); | ||
} | ||
dir = dirname; | ||
} | ||
} | ||
dir = dirname; | ||
} | ||
} | ||
packageDirCache[absModulePath] = dir; | ||
} | ||
packageDirCache[absModulePath] = dir; | ||
} | ||
return dir; | ||
return dir; | ||
} |
Sorry, the diff of this file is not supported yet
91
5702