1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/development/create-static-server.js

24 lines
629 B
JavaScript
Executable File

#!/usr/bin/env node
const http = require('http');
const path = require('path');
const serveHandler = require('serve-handler');
const createStaticServer = (rootDirectory) => {
return http.createServer((request, response) => {
if (request.url.startsWith('/node_modules/')) {
request.url = request.url.substr(14);
return serveHandler(request, response, {
directoryListing: false,
public: path.resolve('./node_modules'),
});
}
return serveHandler(request, response, {
directoryListing: false,
public: rootDirectory,
});
});
};
module.exports = createStaticServer;