According to npm documentation
You should firstly modify package.json
{
...
"preferGlobal": "true",
"directories": {
"bin": "./bin"
},
...
}
Create a directory called lib in your modules folder, and create mypgk.js inside of it.
Then create a script which gets command line params like this
var argv = require('optimist').argv;
if (argv.make === 'deploy') {
//do some stuff here
} else if (argv.make === 'test') {
//another stuff
}
//...
Then install it install -g ./
then you can use it mypgk --make=deploy
If you don't like to pass arguments like I did here you can change the way you do it, refer to this question
P.S Here is brief summary what you need to do, to more precise information refer to the link at the beginning (recommended)