Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.min.*
node_modules

packages/cli/src/lib/live-server/*

packages/core/src/lib/markdown-it/patches/*
packages/core/src/lib/markdown-it/plugins/*
!packages/core/src/lib/markdown-it/plugins/markdown-it-icons.js
Expand Down
2 changes: 1 addition & 1 deletion docs/userGuide/cliCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Usage: markbind <command>

* `-o <file>`, `--one-page <file>`<br>
Serves only a single page from your website **initially**. If `<file>` is not specified, it defaults to `index.md/mbd`.<br>
* Thereafter, when changes to source files have been made, only the page being viewed will be rebuilt if it was affected.<br>
* Thereafter, when changes to source files have been made, the opened pages will be rebuilt if it was affected.<br>
* Navigating to a new page will build the new page, if it has not been built before, or there were some changes to source files that affected it before navigating to it.<br>
* {{ icon_example }} `--one-page guide/index.md`

Expand Down
11 changes: 10 additions & 1 deletion packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Entry file for Markbind project
const chokidar = require('chokidar');
const fs = require('fs-extra');
const liveServer = require('live-server');
const path = require('path');
const program = require('commander');
const Promise = require('bluebird');
Expand All @@ -20,6 +19,7 @@ const {
LAZY_LOADING_SITE_FILE_NAME,
} = require('@markbind/core/src/Site/constants');

const liveServer = require('./src/lib/live-server');
const cliUtil = require('./src/util/cliUtil');
const logger = require('./src/util/logger');

Expand Down Expand Up @@ -139,6 +139,9 @@ program

const addHandler = (filePath) => {
logger.info(`[${new Date().toLocaleTimeString()}] Reload for file add: ${filePath}`);
logger.info('Synchronizing opened pages list before reload');
const normalizedActiveUrls = liveServer.getActiveUrls().map(url => fsUtil.removeExtension(url));
site.changeCurrentOpenedPages(normalizedActiveUrls);
Promise.resolve('').then(() => {
if (site.isFilepathAPage(filePath) || site.isDependencyOfPage(filePath)) {
return site.rebuildSourceFiles(filePath);
Expand All @@ -151,6 +154,9 @@ program

const changeHandler = (filePath) => {
logger.info(`[${new Date().toLocaleTimeString()}] Reload for file change: ${filePath}`);
logger.info('Synchronizing opened pages list before reload');
const normalizedActiveUrls = liveServer.getActiveUrls().map(url => fsUtil.removeExtension(url));
site.changeCurrentOpenedPages(normalizedActiveUrls);
Promise.resolve('').then(() => {
if (site.isDependencyOfPage(filePath)) {
return site.rebuildAffectedSourceFiles(filePath);
Expand All @@ -163,6 +169,9 @@ program

const removeHandler = (filePath) => {
logger.info(`[${new Date().toLocaleTimeString()}] Reload for file deletion: ${filePath}`);
logger.info('Synchronizing opened pages list before reload');
const normalizedActiveUrls = liveServer.getActiveUrls().map(url => fsUtil.removeExtension(url));
site.changeCurrentOpenedPages(normalizedActiveUrls);
Promise.resolve('').then(() => {
if (site.isFilepathAPage(filePath) || site.isDependencyOfPage(filePath)) {
return site.rebuildSourceFiles(filePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"figlet": "^1.2.4",
"find-up": "^4.1.0",
"fs-extra": "^9.0.1",
"live-server": "^1.2.1",
"live-server": "1.2.1",
"lodash": "^4.17.15",
"winston": "^2.4.4",
"winston-daily-rotate-file": "^3.10.0"
Expand Down
Loading