Skip to content

Commit

Permalink
chore(lint): init lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSwitch committed Apr 10, 2021
1 parent 88850c0 commit 1e534ce
Show file tree
Hide file tree
Showing 6 changed files with 1,341 additions and 132 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": "5app"
}
45 changes: 1 addition & 44 deletions bin/localhost
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
#!/usr/bin/env node

'use strict';

var localhost = require('../index.js'),
portfinder = require('portfinder'),
argv = require('optimist')
.boolean('cors')
.argv;

var port = argv.p || parseInt(process.env.PORT, 10);

if (!port) {
portfinder.basePort = 8080;
portfinder.getPort(function (err, port) {
if (err) { throw err; }
listen(port);
});
}
else {
listen(port);
}

function listen(port) {
localhost(argv._[0] || './').listen(port);
console.log("Starting //localhost" + (port !== 80 ? ":" + port : ''));
}

if (process.platform === 'win32') {
require('readline').createInterface({
input: process.stdin,
output: process.stdout
}).on('SIGINT', function () {
process.emit('SIGINT');
});
}

process.on('SIGINT', function () {
console.info('localhost stopped.'.red);
process.exit();
});

process.on('SIGTERM', function () {
console.info('localhost stopped.'.red);
process.exit();
});
require('../server.js');
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var http = require('http');
var serveStatic = require('serve-static');
var finalhandler = require('finalhandler');
const http = require('http');
const serveStatic = require('serve-static');
const finalhandler = require('finalhandler');


module.exports = function(mapping) {

const [directory, basePath] = mapping.split(':');

// Serve up the file
var serve = serveStatic(directory);
const serve = serveStatic(directory);

// Create server
return http.createServer((req, res) => {
Expand All @@ -22,4 +22,4 @@ module.exports = function(mapping) {
const done = finalhandler(req, res);
serve(req, res, done);
});
}
};
Loading

0 comments on commit 1e534ce

Please # to comment.