Skip to content

YellowKirby/add-package-prefix

Repository files navigation

add-package-prefix

build status code coverage code style styled with prettier made with lass license

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

About

Add a (scope-friendly) prefix to an npm package name

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published