1.0.0 • Published 4 years ago

@eugabrielsilva/js-include v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

js-include

This library allows you to include, in-place, common Javascript files (not modules) into your Node.js application and evaluate their script in the global namespace, kind like PHP does.

Installation

npm install @eugabrielsilva/js-include

Usage (single file)

// Declare the module
const includes = require('@eugabrielsilva/js-include');

// Include the file
includes.__includeFile('./inc/myfile.js');
eval(includes.myfile);

Usage (directory)

// Declare the module
const includes = require('@eugabrielsilva/js-include');

// Include the directory
includes.__includeDir('./inc');

for (let file in includes.inc) {
    eval(includes.inc[file]);
}

Credits

Library developed and currently maintained by Gabriel Silva.