Skip to content

Post install script for npm(1) which makes components consumable from node

Notifications You must be signed in to change notification settings

eldargab/component-npm-post-install

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

component-npm-post-install

Post-install script for npm(1) which makes a component to be a valid node module.

It loops through a packages installed in a node_modules dir and creates additional files effectively aliasing short component names with names created by npm(1).

Please note! Post install scripts are considered to be a bad practice. In this concrete case there should not be any practical downside. Nevertheless it is a break for convention. For example, some tool might be confused. So, please, you use this script only for private needs or as a temporary hack.

Usage

Just create a package.json for the component you want to publish and specify component-npm-post-install as a post install script.

{
  "name": "foo",
  "dependencies": {
    "bar": "*",
    "org-baz": "*",
    "org-qux": "org/url-of-foo-on-github",
    "quux-very-strange-npm-suffix-to-avoid-ns-clash": "*",
    "component-npm-post-install": "*"
  },
  "scripts": {
    "postinstall": "component-npm-post-install"
  }
}

As a result you will have addional baz.js, qux.js, quux.js files in node_modules. They have a form of:

baz.js

module.exports = require("org-baz")

For this to work every npm package must include component.json.

Installation

with npm

npm install component-npm-post-install

Related

Another way to consume components from node is to require them.

License

MIT

About

Post install script for npm(1) which makes components consumable from node

Resources

Stars

Watchers

Forks

Packages

No packages published