Skip to content
This repository was archived by the owner on Oct 7, 2019. It is now read-only.

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

gitbook-cli-local

Run gitbook cli commands using a local copy installed with NPM

npm version

Why

Because gitbook-cli installs gitbook to the user home directory and we needed to monkey-patch gitbook from the using project.

Usage

Install gitbook locally with npm:

npm install --save-dev gitbook

Install gitbook-cli-local:

npm install --save-dev @tepez/gitbook-cli-local

Start any gitbook command, e.g. serve:

node node_modules/@tepez/gitbook-cli-local/bin/gitbook.js serve

Or, if you need to make modifications, e.g. monkey-patching, gitbook first:

constParse=require('gitbook/lib/parse');constorigParsePagesList=Parse.parsePagesList;// Monkey-patch parsePagesList to set the direction of a page based on the language// of the book, instead of using wooorm/direction to determine its direction from its content// As is done by gitbook:// https://github.com/GitbookIO/gitbook/blob/3.2.2/lib/parse/parsePageFromString.js#L18// This will fail to recognize a text as Hebrew if the first line is for example// `# {{ page.title }}`Parse.parsePagesList=function(book){constlanguage=book.getConfig().getValue('language');returnorigParsePagesList.apply(this,arguments).then((pages)=>{if(language==='he'){returnpages.map((page)=>page.set('dir','rtl'));}returnpages;})};require('@tepez/gitbook-cli-local/bin/gitbook.js');

About

Run gitbook cli commands using a local copy installed with NPM

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages