0.0.3 • Published 5 years ago
@marianc/npm-boilerplate v0.0.3
About the code
This code can be used as a starting point for a new nodejs module. It has various tools configured for transpiling, testing, linting, building and deployment. You could clone it, remove the .git folder, change all the npm-boilerplate references and commit it to your own repo.
Commands
yarn run clean
- Removesdist/
directoryyarn run examples
- Runs the examplesyarn run examples:watch
- Runs examples in watch modeyarn run test
- Tests in jest with coverageyarn run test:watch
- Run tests in watch mode with coverageyarn run lint
- Linter based on eslintyarn run build
- Alias of build:node + build:webyarn run build:node
- Babel transpiler (ES6 => ES5 + minify).yarn run build:web
- Builder for web/browsersyarn run prepare
- Hook for npm. Do all the checks before publishing your module.yarn run deploy
- Uses the np module to deploy the npm module (tags, releases, versioning)
NPM Publishing
In order to publish this package to NPM you will need to have an account and package.json updated to your preferences. This repo also comes with pm which makes the process a bit better. Check out more on creating-and-publishing-scoped-public-packages or np
Using the module
In order to use this as a nodejs module you will need to include it as a regular package:
yarn add @marianc/npm-boilerplate
const { isWeekend } = require('@marianc/npm-boilerplate');
console.log(isWeekend(new Date()));
Or just use this Runkit
Or as a cli :
npm install -g @marianc/npm-boilerplate
isweekend
# Today is weekday
Or as a script for your browser
<script src="https://unpkg.com/@marianc/npm-boilerplate@0.0.1/dist/index.web.js"></script>
<script>
try {
var weekend = isWeekend(new Date());
console.log(`Today is ${weekend ? 'Weekend': 'Weekday' }`)
} catch (ex) {
console.log(ex);
}
</script>
Or check this Playcode