// all files in the provided directory use this general formatmodule.exports=function(Config){varapp={};console.log('Initialize some sort of app here');returnapp;}
/src/Config.js
module.exports={whateverYouWantHere: 'yeah'}
/src/util/Decorator.js
module.exports=function(App){// this will evaluate since it is referencing an active resourceApp.name='Decorated App';}
/sorcerer.config.js
module.exports={basePath: __dirname,// default: execution directoryverbose: true,// default: false (you can use strings/arrays to allow verbosity in specific environments)packages: [{env: 'production',// use specified env (process.env.NODE_ENV by default)path: '/src',// you can also just pass the path string instead of a config object},{name: 'globals',// optionalinclude: {// note that you can use both `path` and `include` in the same packageConfig: ()=>'Some example resource',},}],};
/index.js
// simple example (no config object)require('sorc')(__dirname+'/src','App');// using externalized configvarconfig=require('./sorcerer.config');// configure a directoryrequire('sorc')(config,(App)=>{// You can use any file as an entry pointconsole.log(App);});// or, configure a directory with a specified environmentrequire('sorc')(config,'test',(App,Config)=>{console.log(App,Config);});// or, configure a directory with error handlingrequire('sorc')(config,(err,App)=>{if(err)returnconsole.error(err);console.log(App);});