@rnx-kit/tools-node
Advanced tools
Comparing version 1.2.7 to 1.3.0
@@ -101,3 +101,3 @@ /** | ||
/** | ||
* Optional flag controlling whether or symlinks can be found. Defaults to `true`. | ||
* Optional flag controlling whether symlinks can be found. Defaults to `true`. | ||
* When `false`, and the package dependency directory is a symlink, it will not | ||
@@ -107,2 +107,7 @@ * be found. | ||
allowSymlinks?: boolean; | ||
/** | ||
* Optional flag controlling whether to resolve symlinks. Defaults to `false`. | ||
* Note that this flag has no effect if `allowSymlinks` is `false`. | ||
*/ | ||
resolveSymlinks?: boolean; | ||
}; | ||
@@ -109,0 +114,0 @@ /** |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -9,4 +32,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
const pkg_dir_1 = __importDefault(require("pkg-dir")); | ||
@@ -74,4 +97,4 @@ const pkg_up_1 = __importDefault(require("pkg-up")); | ||
function resolvePackagePath(pkgPath) { | ||
if (path_1.default.basename(pkgPath).toLowerCase() !== "package.json") { | ||
return path_1.default.join(pkgPath, "package.json"); | ||
if (path.basename(pkgPath).toLowerCase() !== "package.json") { | ||
return path.join(pkgPath, "package.json"); | ||
} | ||
@@ -88,3 +111,3 @@ return pkgPath; | ||
const pkgFile = resolvePackagePath(pkgPath); | ||
return JSON.parse(fs_1.default.readFileSync(pkgFile, "utf-8")); | ||
return JSON.parse(fs.readFileSync(pkgFile, "utf-8")); | ||
} | ||
@@ -101,3 +124,3 @@ exports.readPackage = readPackage; | ||
const pkgFile = resolvePackagePath(pkgPath); | ||
fs_1.default.writeFileSync(pkgFile, JSON.stringify(manifest, undefined, space) + "\n", "utf-8"); | ||
fs.writeFileSync(pkgFile, JSON.stringify(manifest, undefined, space) + "\n", "utf-8"); | ||
} | ||
@@ -147,6 +170,12 @@ exports.writePackage = writePackage; | ||
var _a; | ||
const pkgName = typeof ref === "string" ? ref : path_1.default.join((_a = ref.scope) !== null && _a !== void 0 ? _a : "", ref.name); | ||
return find_up_1.default.sync(path_1.default.join("node_modules", pkgName), Object.assign(Object.assign({}, (0, properties_1.pickValues)(options !== null && options !== void 0 ? options : {}, ["startDir", "allowSymlinks"], ["cwd", "allowSymlinks"])), { type: "directory" })); | ||
const pkgName = typeof ref === "string" ? ref : path.join((_a = ref.scope) !== null && _a !== void 0 ? _a : "", ref.name); | ||
const packageDir = find_up_1.default.sync(path.join("node_modules", pkgName), Object.assign(Object.assign({}, (0, properties_1.pickValues)(options !== null && options !== void 0 ? options : {}, ["startDir", "allowSymlinks"], ["cwd", "allowSymlinks"])), { type: "directory" })); | ||
if (!packageDir || !(options === null || options === void 0 ? void 0 : options.resolveSymlinks)) { | ||
return packageDir; | ||
} | ||
return fs.lstatSync(packageDir).isSymbolicLink() | ||
? path.resolve(path.dirname(packageDir), fs.readlinkSync(packageDir)) | ||
: packageDir; | ||
} | ||
exports.findPackageDependencyDir = findPackageDependencyDir; | ||
//# sourceMappingURL=package.js.map |
{ | ||
"name": "@rnx-kit/tools-node", | ||
"version": "1.2.7", | ||
"version": "1.3.0", | ||
"description": "A collection of supplemental NodeJS functions and types", | ||
@@ -41,3 +41,3 @@ "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/tools-node#readme", | ||
"@types/node": "^16.0.0", | ||
"jest-extended": "^0.11.5", | ||
"jest-extended": "^2.0.0", | ||
"temp-dir": "^2.0.0" | ||
@@ -51,5 +51,5 @@ }, | ||
"setupFilesAfterEnv": [ | ||
"jest-extended" | ||
"jest-extended/all" | ||
] | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
<!--remove-block start--> | ||
# @rnx-kit/tools-node | ||
@@ -6,2 +8,4 @@ | ||
<!--remove-block end--> | ||
`@rnx-kit/tools-node` is a collection of supplemental NodeJS functions and | ||
@@ -8,0 +12,0 @@ types. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
611
60
43280
30