Skip to content

Commit

Permalink
Updating deps and finishing off the recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
stolksdorf committed Mar 27, 2020
1 parent 02c7fbf commit 7f50aa6
Show file tree
Hide file tree
Showing 7 changed files with 1,790 additions and 2,552 deletions.
2 changes: 1 addition & 1 deletion lib/filewatch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const nodemon = require('nodemon');
const path = require('path');
const {chalk} = require('./utils.js');
const chalk = require('../utils/chalk.js');

const rel = (filepath)=>path.relative(process.cwd(), filepath);

Expand Down
2 changes: 1 addition & 1 deletion lib/livereload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const livereload = require('livereload');
const {chalk} = require('./utils.js');
const chalk = require('../utils/chalk.js');

module.exports = (watchPath=process.cwd())=>{
const lr = livereload.createServer();
Expand Down
5 changes: 1 addition & 4 deletions lib/simple.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const url = require('url');
const fs = require('fs').promises;
const path = require('path');

const {chalk} = require('./utils.js');
const chalk = require('../utils/chalk.js');

const getMIMEType = (ext)=>{
const types = {
Expand Down Expand Up @@ -34,7 +34,6 @@ const getFile = async (pathname, rootDir)=>{
const ext = path.extname(pathname);
if(ext == '') return getFile(pathname + '/index.html', rootDir);
const loc = path.join(rootDir, pathname);
console.log(loc)
try{
return { ext, contents : await fs.readFile(loc), loc }
}catch(err){
Expand All @@ -49,9 +48,7 @@ module.exports = (rootDir=process.cwd(), opts={})=>{
return new Promise((resolve, reject)=>{
http.createServer(async (req, res)=>{
let pathname = url.parse(req.url).pathname.replace(/\/$/, '');
console.log(pathname)
if(pathname.startsWith(opts.basepath)) pathname = pathname.replace(opts.basepath, '');
console.log(pathname)
const { contents, ext, loc } = await getFile(pathname, rootDir);
if(contents === false){
res.statusCode = 404;
Expand Down
Loading

0 comments on commit 7f50aa6

Please sign in to comment.