Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix lint issues
  • Loading branch information
Damien Guerin committed Jan 17, 2020
commit e74b9d8e55b01deafc16fc65b9189dfe227c8987
53 changes: 26 additions & 27 deletions lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,58 +25,57 @@ module.exports = function (
livereloadPort = p
})
.then(_ => {
const server = connect();
const server = connect()
server.use(
livereload({
port: livereloadPort
})
);
)

let indexFileFound = false;
let indexFile;
path.split(",").forEach((path)=> {
path = resolve(path || ".");
indexFile = resolve(path, indexName || "index.html");
let indexFileFound = false
let indexFile
path.split(',').forEach(path => {
path = resolve(path || ',')
indexFile = resolve(path, indexName || 'index.html')
if (exists(indexFile)) {
indexFileFound = true
}
server.use(serveStatic(path, { index: indexName }));
});

server.use(serveStatic(path, {index: indexName}))
})

if (!indexFileFound) {
const msg =
"\nNo docs found " +
'\nNo docs found ' +
indexFile +
"\nPlease run " +
chalk.green("docsify init") +
" first.\n";
console.log(msg);
process.exit(0);
'\nPlease run ' +
chalk.green('docsify init') +
' first.\n'
console.log(msg)
process.exit(0)
}



server.listen(port);
server.listen(port)
lrserver
.createServer({
extraExts: ["md"],
exclusions: ["node_modules/"],
extraExts: ['md'],
exclusions: ['node_modules/'],
port: livereloadPort
})
.watch(path.split(","));
.watch(path.split(','))

if (openInBrowser) {
open(`http://localhost:${port}`);
open(`http://localhost:${port}`)
}

const msg =
"\nServing " +
'\nServing ' +
chalk.green(`${path}`) +
" now.\n" +
"Listening at " +
' now.\n' +
'Listening at ' +
chalk.green(`http://localhost:${port}`) +
"\n";
console.log(msg);
'\n'
console.log(msg)
})
.catch(err => {
console.error(err.message)
Expand Down