html-pages
Version:
Simple development HTTP Server for file serving and directory listing made by a Designer. Use it for hacking your HTML/JavaScript/CSS files but not for deploying your final site.
30 lines (23 loc) • 529 B
JavaScript
// Native
const path = require('path');
const spawn = require('child_process').spawn;
// Packages
const dargs = require('dargs');
module.exports = (directory = process.cwd(), options = {}) => {
const scriptPath = path.join(__dirname, '..', 'bin', 'index.js');
const aliases = {};
options.root = [directory];
const args = [scriptPath, ...dargs(options, {
aliases
})];
const cli = spawn('node', args, {
stdio: 'inherit'
});
return {
cli,
stop () {
cli.kill();
},
options
};
};