@dbux/common-node
Advanced tools
Comparing version 0.6.3 to 0.6.4-dev.1
{ | ||
"name": "@dbux/common-node", | ||
"version": "0.6.3", | ||
"version": "0.6.4-dev.1", | ||
"description": "", | ||
@@ -12,3 +12,3 @@ "module": "src/index.js", | ||
"dependencies": { | ||
"@dbux/common": "^0.6.3", | ||
"@dbux/common": "^0.6.4-dev.1", | ||
"adm-zip": "^0.5.9", | ||
@@ -30,3 +30,3 @@ "colors": "^1.4.0", | ||
"_moduleAliases": {}, | ||
"gitHead": "92dd244aa0d1c7b4dd230b2d538be1db0383b7c2" | ||
"gitHead": "68ae661ec58644650c06aa807748d1551d4b2cc1" | ||
} |
import sh from 'shelljs'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import commonAncestorPath from 'common-ancestor-path'; | ||
import { homedir } from 'os'; | ||
import _commonAncestorPath from 'common-ancestor-path'; | ||
import EmptyObject from '@dbux/common/src/util/EmptyObject'; | ||
@@ -71,17 +72,2 @@ | ||
export function parseNodeModuleName(fpath) { | ||
fpath = pathNormalized(fpath); | ||
const matchResult = fpath.match(/(?<=node_modules[/])(?!node_modules)(?<packageName>[^/]+)(?=[/](?!node_modules)(?<name2>[^/]+).*?)/); | ||
let { packageName, name2 } = matchResult?.groups || EmptyObject; | ||
if (!packageName) { | ||
return null; | ||
} | ||
if (packageName.startsWith('@') && name2) { | ||
// only a prefix | ||
packageName += '/' + name2; | ||
// console.warn('module match:', packageName, name2); | ||
} | ||
return packageName || null; | ||
} | ||
export function getPathRelativeToCommonAncestor(fpath, ...otherPaths) { | ||
@@ -100,3 +86,6 @@ const common = getCommonAncestorPath(fpath, ...otherPaths); | ||
export function getCommonAncestorPath(...paths) { | ||
return commonAncestorPath(...paths); | ||
// NOTE: the library requires OS-specific separators | ||
paths = paths.map(p => path.resolve(p)); | ||
const result = _commonAncestorPath(...paths); | ||
return pathNormalized(result); | ||
} | ||
@@ -108,1 +97,9 @@ | ||
} | ||
export function renderPath(fpath) { | ||
const home = homedir(); | ||
if (fpath.startsWith(home)) { | ||
fpath = '~' + fpath.substring(home.length); | ||
} | ||
return fpath; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38653
18
801
Updated@dbux/common@^0.6.4-dev.1