import log from './log'
log.success("hello green message!")
log.error("hello red message!")
log.warn("hello yellow message!")
log.info("hello cyan message!")
log.log("hello normal message!")
Copy the code
Slowly discovered that every project needs such a log file, yes! We can now consider these commonly used functions encapsulated in an NPM package!
What do you need to pay attention to
Unit testing
Considering the increase in code volume and the increase in contributors, it is necessary to include unit tests beforehand
Test Framework – Mocha is a rich Javascript test framework that runs in Node.js and browsers and supports BDD, TDD, QUnit, and Exports tests
Assertion library – Assert is shipped with Node
Continuous integration
Travis CI provides Continuous Integration, or CI. It is tied to projects on Github and automatically grabs new code whenever it comes in. Then, provide a running environment, perform tests, complete the build, and deploy to the server.
The code level
Extend open to modify the design principles of close
When a utility file is added to the SRC directory, index.ts is automatically captured and mounted on module.export
Use the getter to implement the lazy export function