project-core
Installation
$ npm install project-core --save
Notes: only support Node.js v6.0 or above
Usage
'use strict'; const ProjectCore = ; // create new instanceconst $ = global$ = ; // util functions, extends from lei-utilsconsole;// add your own function$utils {}; // extends$; // init queue// all the functions that added to init queue will be called sequentially$init;$init;// support async function (don't need to use callback)$init; // add file or dir to init queue$init; // events// ready: will be emitted when project inited$event;// you can emit a custom event$event; // add ready event listener// if project was inited, callback immediately$; // config$config;console;console; // init$;
Configuration file
JavasSript file
exmaple file dev.js
:
module { ; // use the get(name) and has(name) to get specific config value // you can also use this.set(), this.get() and this.has() // for exmaple: this.set('we.session.secret') };
use $.config.load('/path/to/dev.js')
or $.config.load('/path/to/dev')
to load this config file.
JSON file
example file dev.json
:
use $.config.load('/path/to/dev.json')
to load this config file.
YAML file
example file dev.yaml
(or dev.yml
):
web: session: secret: '11111111'
use $.config.load('/path/to/dev.yaml')
to load this config file.
project-core
Extends and republish your own 'use strict'; const ProjectCore = ; const $ = ; // extends example$;$;$;$;$; // do something when ready$event; // exportsmoduleexports = $;
or:
'use strict'; const ProjectCore = ; { super; // do something } { // do something before init... // and then call super.init() super; }
License
The MIT License (MIT)
Copyright (c) 2016 Zongmin Lei <leizongmin@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.