@mnrendra/use-package
v1.0.0
Published
A utility to provide package.json data.
Downloads
1
Maintainers
Readme
@mnrendra/use-package
A utility to provide package.json
data. Because @mnrendra/read-package is expensive, this utility is used to save it.
Install
npm i @mnrendra/use-package
Usage
Using CommonJS
:
index.js
const { clonePackage } = require('@mnrendra/use-package')
const submodule = require('./submodule')
const main = async () => {
await clonePackage()
submodule()
}
submodule.js
const { pack } = require('@mnrendra/use-package')
const main = () => {
pack.customField = 'customField'
console.log(pack.name) // Will print your package.json name.
console.log(pack.version) // Will print your package.json version.
console.log(pack.customField) // Will print your package.json customField.
}
Using ES Module
:
index.js
import { clonePackage } from '@mnrendra/use-package'
import submodule from './submodule'
const main = async () => {
await clonePackage()
submodule()
}
submodule.js
import { pack } from '@mnrendra/use-package'
const main = () => {
pack.customField = 'customField'
console.log(pack.name) // Will print your package.json name.
console.log(pack.version) // Will print your package.json version.
console.log(pack.customField) // Will print your package.json customField.
}
Types
import type {
Package // @mnrendra/types-package
} from '@mnrendra/use-package'