forked from petersalomonsen/wasm-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanycommits.worker.js
41 lines (36 loc) · 1023 Bytes
/
manycommits.worker.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
let stdout = [];
let stderr = [];
globalThis.wasmGitModuleOverrides = {
'print': (text) => {
console.log(text);
stdout.push(text)
},
'printErr': (text) => {
console.error(text);
stderr.push(text);
}
};
const lg2mod = await import(new URL('lg2.js', import.meta.url));
const lg2 = await lg2mod.default();
const FS = lg2.FS;
const MEMFS = lg2.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]');
FS.mkdir('/working/testrepo');
FS.chdir('/working/testrepo');
lg2.callMain(['init', '.']);
lg2.callMain(['config', 'user.name', 'Test']);
lg2.callMain(['config', 'user.email', '[email protected]']);
let text = '';
for (let i = 0; i < 10; i++) {
console.log(i);
text += 'x';
FS.writeFile('./test.txt', text);
lg2.callMain(['add', '.']);
lg2.callMain(['commit', '-m', 'commit ' + (i + 1)]);
}
postMessage(stderr);