![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@anolilab/package-json-utils
Advanced tools
Readme
Daniel Bannert's open source work is supported by the community on GitHub Sponsors
npm install @anolilab/package-json-utils
yarn add @anolilab/package-json-utils
pnpm add @anolilab/package-json-utils
const { pkg } = require('@anolilab/package-json-utils');
console.log(pkg.name); // will print the name of the "process.cwd()" package.json
List of available helpers:
hasPackageProperties
This function takes an array of property names as input and checks if the "process.cwd()" package.json object has any of those properties.
hasPackageSubProperties
This function takes a package property name as input and returns a new function that checks if the "process.cwd()" package.json object has sub-properties under the specified package property.
environmentIsSet
This function takes an environment variable name as input and checks if the environment variable is set and not equal to "undefined".
parseEnvironment
This function takes an environment variable name and a default value as input. It attempts to parse the value of the environment variable as JSON and returns the parsed value. If parsing fails, it returns the original value as a string.
appDirectory
This variable is assigned the value of the directory name of the package path or an empty string if the package path is undefined.
fromRoot
This function takes a variable number of path segments as input and joins them with the appDirectory to create a complete path from the root directory.
hasFile
This function takes a variable number of path segments as input and checks if a file exists at the specified path relative to the appDirectory.
hasScripts
This variable is assigned the result of calling hasPackageSubProperties with the argument "scripts". It checks if the "process.cwd()" package.json object has any scripts defined.
hasPeerDep
This variable is assigned the result of calling hasPackageSubProperties with the argument "peerDependencies". It checks if the "process.cwd()" package.json object has any peer dependencies defined.
hasDep
This variable is assigned the result of calling hasPackageSubProperties with the argument "dependencies". It checks if the "process.cwd()" package.json object has any regular dependencies defined.
hasDevelopmentDep
This variable is assigned the result of calling hasPackageSubProperties with the argument "devDependencies". It checks if the "process.cwd()" package.json object has any development dependencies defined.
hasAnyDep
This function takes an array of dependency names as input and checks if any of the dependency checks (hasDep, hasDevelopmentDep, hasPeerDep) return true for any of the dependencies.
hasTypescript
This variable is assigned the result of checking if "typescript" is a dependency and if "tsconfig.json" file exists using hasAnyDep and hasFile functions.
packageIsTypeModule
This variable is assigned the result of checking if the "process.cwd()" package.json object has a property "type" and its value is "module".
isPackageAvailable
This function takes a module name as input and checks if the module is available for import. It uses different methods depending on the environment and package type (module or commonjs).
showMissingPackages
This function takes a package name and an array of missing package names as input and logs a warning message with instructions on how to install the missing packages using npm, yarn, or pnpm.
unique
This function takes an array as input and returns a new array with only unique values.
pkg
This variable returns the "process.cwd()" package.json object or undefined.
getPackageProperty
This function takes a package property name as input and returns the value of the property from the "process.cwd()" package.json object or undefined.
getPackageSubProperty
This function takes a package property name and a sub-property name as input and returns the value of the sub-property from the "process.cwd()" package.json object or undefined.
Note: The process.cwd() method is an inbuilt application programming interface of the process module which is used to get the current working directory of the node.js process.
Libraries in this ecosystem make the best effort to track Node.js’ release schedule. Here’s a post on why we think this is important.
If you would like to help take a look at the list of issues and check our Contributing guild.
Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
The anolilab javascript-style-guide is open-sourced software licensed under the MIT license
FAQs
Shared utilities for parsing information from a package.json.
The npm package @anolilab/package-json-utils receives a total of 219 weekly downloads. As such, @anolilab/package-json-utils popularity was classified as not popular.
We found that @anolilab/package-json-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.