whale-makelink是一个npm工具,是强业务的工具,能够将当前工程目录下的项目文件夹,在README中生成项目的连接地址。Demo。node
1、npm initgit
使用npm init生成package.jsongithub
{
"name": "whale-makelink",
"version": "1.0.5",
"description": "Make-link can get all the project folders of the current directory, and generate the project link directory in the readme.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@github.com:jingwhale/whale-makelink.git"
},
"keywords": [
"makelink"
],
"author": "jingwhale@yeah.net",
"license": "ISC"
}
2、自定义命令npm
2.一、在package.json的bin下定义一个对象,这里makelink就是须要的命令,内容交给index.jsjson
{
"name": "whale-makelink",
"version": "1.0.5",
"description": "Make-link can get all the project folders of the current directory, and generate the project link directory in the readme.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@github.com:jingwhale/whale-makelink.git"
},
"bin": {
"makelink": "./index.js"
},
"keywords": [
"makelink"
],
"author": "jingwhale@yeah.net",
"license": "ISC"
}
2.二、在index.js中添加'#!/usr/bin/env node'svg
#!/usr/bin/env node const path = require('path'); const makelink = require('./makelink'); const pathName = path.resolve(__dirname, '../..'); const srcFile = pathName + '/README.md'; makelink(srcFile,pathName);
3、发布npm包工具
3.一、注册ui
npm官网注册,而且经过邮件验证后,才能发npm包。url
3.二、登陆spa
npm login
输入用户名、密码和邮箱。
3.三、发布
npm publish
3.四、版本更新
1)、变动版本号-自动改变版本
npm version <update_type>
update_type为patch, minor, or major其中之一,分别表示补丁,小改,大改
如果patch,变为1.0.1 如果minor,变为1.1.0 如果major,变为2.0.0
2)、发布
npm publish
3.五、发布出错
1)、验证邮箱
2)、修正npm源
npm config get registry npm config set registry=http://registry.npmjs.org
4、更新package.json
更新package.json后,须要先提交到github,再进行版本的升级。
建立
readme中使用

策略
每次代码更新完毕,在进行版本的升级操做。