Comments (2)
GitKit works great with browserify or Webpack.
I can also build a dist js to be released on NPM, so that you can use it in webpage (But I think using browserify is a better solution):
<script src="./node_modules/gitkit/dist/gitkit.js"></script>
<script>
var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');
</script>
I'll add a note about this in the readme.
from gitkit-js.
I colleague asked me about this today, so I wrote together a little step by step howto, maybe this helps other people too:
# Create a local test directory and cd into it
mkdir gitkit-tests; cd gitkit-tests
# The current npm package does not contain the latest changes
# To have (browser-enabled) Memory filesystem we need to install
# from github
npm install SamyPesse/gitkit-js
# Install a required dependency
npm install mkdirp
# Install browserify globally
npm install browserify -g
# Bundle up gitkit and MemoryFS and wrap them in a require
# function so that you can use require in the browser
browserify -r gitkit -r gitkit/lib/fs/memory -o bundle.js
# Hack to bypass “same origin” policy
# when you develop a browser extension, this shouldn’t be a problem
# cf. https://developer.chrome.com/extensions/xhr#extension-origin
sed -i.bak 's/cors/no-cors/g' bundle.js
# Create an html file that loads the bundle.js
echo "<script src='bundle.js'></script>" > index.html
Now you can fire up the html page in a browser and use the browser’s
console and use require just like in the node console, e.g.:
# In the browser's developer console
var GitKit = require('gitkit');
var MemoryFS = require('gitkit/lib/fs/memory');
var fs = MemoryFS()
var repo = GitKit.Repository.createWithFS(fs, true);
var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');
# And so on ...
from gitkit-js.
Related Issues (14)
- Implement fs instance for browser HOT 1
- API methods
- Add table of comparison with nodegit.org HOT 4
- Path must be a string. Received undefined
- Comparison with js-git: https://github.com/creationix/js-git
- Add operation complains about a missing index file
- [bounty] Shallow Clone a Tag
- Trying to get in touch regarding a security issue
- Publish a complete documentation as a GitBook
- Incorrect link to license file in README.md
- Add support for npm HOT 4
- Remove requirement for git for installation HOT 2
- Please provide TypeScript definitions for the library HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitkit-js.