forked from petersalomonsen/wasm-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_node.js
50 lines (33 loc) · 1.21 KB
/
example_node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const lg = require('./lg2.js');
lg.onRuntimeInitialized = () => {
const FS = lg.FS;
const MEMFS = FS.filesystems.MEMFS;
FS.mkdir('/working');
FS.mount(MEMFS, { }, '/working');
FS.chdir('/working');
FS.writeFile('/home/web_user/.gitconfig', '[user]\n' +
'name = Test User\n' +
'email = [email protected]');
// clone a repository from github
lg.callMain(['clone','https://github.com/torch2424/made-with-webassembly.git','clonedtest']);
FS.chdir('clonedtest');
console.log(FS.readdir('.'));
lg.callMain(['log']);
FS.chdir('..');
// create an empty git repository and create some commits
lg.callMain(['init','testrepo']);
FS.chdir('testrepo');
FS.writeFile('test.txt', 'hello');
lg.callMain(['add', '--verbose', 'test.txt']);
lg.callMain(['commit','-m','test 123']);
lg.callMain(['log']);
lg.callMain(['status']);
lg.callMain(['status']);
FS.writeFile('test.txt', 'second revision');
lg.callMain(['add', 'test.txt']);
lg.callMain(['status']);
lg.callMain(['commit','-m','test again']);
lg.callMain(['status']);
lg.callMain(['log']);
FS.chdir('..');
};