Created
November 24, 2018 11:53
-
-
Save raoulmillais/78efeaaf2752967d3cc8596b90821046 to your computer and use it in GitHub Desktop.
Demonstration of isomorphic-git clone problem using parcel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>isomorphic-git clone bug</title> | |
</head> | |
<body> | |
<header> | |
<h1 id="status">Open the console</h1> | |
</header> | |
<main> | |
<pre id="output"></pre> | |
</main> | |
<script src="https://isomorphic-git.org/js/browserfs.js"></script> | |
<script src="./index.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('babel-polyfill') | |
const pify = require('pify') | |
const git = require('isomorphic-git') | |
let fsOptions = { | |
fs: 'IndexedDB', | |
options: {} | |
} | |
window.BrowserFS.configure(fsOptions, async (err) => { | |
if (err) return console.log(err) | |
const fs = window.BrowserFS.BFSRequire('fs') | |
// Initialize isomorphic-git with our new file system | |
git.plugins.set('fs', fs) | |
// make a Promisified version for convenience | |
const pfs = window.pfs = pify(fs) | |
const dir = window.dir = '/tutorial' | |
console.log(dir) | |
console.log(await pfs.mkdir(dir)) | |
// Behold - it is empty! | |
console.log(await pfs.readdir(dir)) | |
await git.clone({ | |
dir, | |
corsProxy: 'https://cors.isomorphic-git.org', | |
url: 'https://github.com/isomorphic-git/isomorphic-git', | |
ref: 'master', | |
singleBranch: true, | |
depth: 10 | |
}) | |
// Now it should not be empty... | |
console.log(await pfs.readdir(dir)) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "isomorphic-git-bug", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "parcel index.html", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"parcel-bundler": "^1.10.3" | |
}, | |
"dependencies": { | |
"@babel/cli": "^7.1.5", | |
"@babel/core": "^7.1.6", | |
"@babel/preset-env": "^7.1.6", | |
"babel-polyfill": "^6.26.0", | |
"isomorphic-git": "^0.40.0", | |
"pify": "^4.0.1" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment