@tunnckocore/utils
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.7.0](https://github.com/tunnckoCore/opensource/compare/@tunnckocore/utils@0.6.0...@tunnckocore/utils@0.7.0) (2019-09-20) | ||
### Features | ||
* improve tests, rename packageRootPath -> workspaceRootPath ([25b60ee](https://github.com/tunnckoCore/opensource/commit/25b60ee)) | ||
# [0.6.0](https://github.com/tunnckoCore/opensource/compare/@tunnckocore/utils@0.5.3...@tunnckocore/utils@0.6.0) (2019-09-19) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"name": "@tunnckocore/utils", | ||
@@ -38,3 +38,3 @@ "description": "Utility functions and helpers for internal usage and monorepos", | ||
], | ||
"gitHead": "8a0ca03bbc3ee827575d88353f0e89dbb5d70782" | ||
"gitHead": "abea3d3a4687b2707e1123b1aa39c4e8e47cac8b" | ||
} |
@@ -12,2 +12,4 @@ const fs = require('fs'); | ||
// we cannot test it because we are in monorepo where the cwd is. | ||
/* istanbul ignore next */ | ||
function isMonorepo(cwd = process.cwd()) { | ||
@@ -29,3 +31,2 @@ const { workspaces } = getWorkspacesAndExtensions(cwd); | ||
function createAliases(cwd = process.cwd(), sourceDirectory) { | ||
// const { workspaces, extensions, exts } = getWorkspacesAndExtensions(cwd); | ||
const result = getWorkspacesAndExtensions(cwd); | ||
@@ -42,3 +43,2 @@ | ||
.map((directory) => { | ||
// console.log(workspace); | ||
const pkgDirectory = path.join(workspace, directory); | ||
@@ -56,2 +56,3 @@ const pkgJsonPath = path.join(pkgDirectory, 'package.json'); | ||
return null; | ||
// skip silently | ||
// throw new Error( | ||
@@ -81,3 +82,11 @@ // `Cannot find package.json or cannot parse it: ${pkgJsonPath}`, | ||
function parseJson(fp) { | ||
return fs.existsSync(fp) ? JSON.parse(fs.readFileSync(fp, 'utf8')) : {}; | ||
if (fs.existsSync(fp)) { | ||
let res = {}; | ||
try { | ||
res = JSON.parse(fs.readFileSync(fp, 'utf8')); | ||
} catch (err) {} | ||
return res; | ||
} | ||
return {}; | ||
} | ||
@@ -111,3 +120,3 @@ | ||
const fpath = [lernaJsonPath, packageJsonPath].find((x) => fs.existsSync(x)); | ||
const packageRootPath = fpath ? path.dirname(fpath) : null; | ||
const workspaceRootPath = fpath ? path.dirname(fpath) : null; | ||
@@ -122,4 +131,4 @@ return { | ||
packageJsonPath, | ||
packageRootPath, | ||
workspaceRootPath, | ||
}; | ||
} |
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
6556
108