Create Package.json File
// NPM settingsnpm set Init-author-name ' username 'npm set init-author-email ' [email protected] 'NPM Set init-author-url ' http://username.com 'npm set savetrue//Create Package.json NPM Init
Pubish to GitHub and tag it
--M "Commit message"1.0.0--tags
Publish to NPM
<project_name>
Release a new version
inch Package.json2. Publish to Git3. Publish tag to git4. NPM Publish5. NPM Info
Publishing a beta version
1. In Package.json: ' Version ': ' 1.2.0-beta.0 ',2. Publish to Git in gitbeta 5. NPM info//installnpm install starwars-[email protected]npm install starwars[ Email protected]
Mocha, Chai Testing:
varExpect = require (' Chai ')). Expect;varStarWars = require ('./index '));d Escribe (' Starwars-names ',function() {Describe (' All ',function(){ //Check return typeIt (' should is an array of strings ',function() {expect (Starwars.all). to.satisfy (isarrayofstring); functionisarrayofstring (array) {returnArray.every (function(item) {return typeofitem = = = ' String '; }); } }); //Ccheck One of the valueIt (' Should includ Asajj Ventress ',function() {expect (Starwars.all). To.include (' Asajj Ventress '); }); }); Describe (' Random ',function() {It (' Should return one of the Starwar names form all ',function() {expect (Starwars.all). To.include (Starwars.random ()); }) });});
[Javascript] How to write a Javascript libarary