add-package-prefix
v1.0.2
Published
Add a (scope-friendly) prefix to an npm package name
Downloads
6
Maintainers
Readme
add-package-prefix
Add a (scope-friendly) prefix to an npm package name
Useful when you have a tool that allows package name shorthands. e.g., babel
plugins are resolved by either the direct package name or
babel-plugin-${packageName}
.
Table of Contents
Install
npm:
npm install add-package-prefix
yarn:
yarn add add-package-prefix
Usage
addPackagePrefix(prefix : string, packageName : string)
Prefixes the packageName
with the given prefix
, ignoring any package
scope. Automatically converts spaces to hyphens. prefix
will not be added if packageName
already contains the prefix
.
const addPackagePrefix = require('add-package-prefix');
addPackagePrefix('babel-plugin', 'my-cool-project'); // => 'babel-plugin-my-cool-project'
addPackagePrefix('webpack-plugin', '@scope/awesome-thing'); // => '@scope/webpack-plugin-awesome-thing'
addPackagePrefix('yep yep', 'this is fun'); // => 'yep-yep-this-is-fun'
addPackagePrefix('babel-plugin', 'babel-plugin-something'); // => 'babel-plugin-something'
Contributors
| Name | | --------------- | | YellowKirby |
License
MIT © YellowKirby