diff --git a/src/home.js b/src/home.js index 9d2d1aa..4ac2dad 100644 --- a/src/home.js +++ b/src/home.js @@ -18,7 +18,7 @@ function shareAppFolder (name, entry) { let [userId = '*', permissions = 'r', branch = '*'] = entry?.split(':') || [] - if (!aclJson.ACL[userId]) aclJson[userId] = { [branch]: permissions } + if (!aclJson.ACL[userId]) aclJson.ACL[userId] = { [branch]: permissions } fs.writeFileSync(p, JSON.stringify(aclJson)) } @@ -58,7 +58,7 @@ function isShared (name) { function getACL (name) { if (!fs.existsSync(`${APP_HOME}/${name}/.git-daemon-export-ok`)) throw new Error('Repo is not shared') - const aclFile = fs.readFileSync(`${APP_HOME}/${name}/.git-daemon-export-ok`, 'r') + const aclFile = fs.readFileSync(`${APP_HOME}/${name}/.git-daemon-export-ok`, 'utf8') aclJson = JSON.parse(aclFile || '{ "protectedBranches": [], "ACL": {}}') return aclJson } diff --git a/src/rpc-request.js b/src/rpc-request.js deleted file mode 100644 index e69de29..0000000 diff --git a/test/home.test.js b/test/home.test.js index 115b014..2381886 100644 --- a/test/home.test.js +++ b/test/home.test.js @@ -9,33 +9,33 @@ test('getAppHome', t => { }) test('createAppFolder, share, is shared, unshare, isInitialized, list, getCodePath', t => { - home.createAppFolder('test') + home.createAppFolder('test_code') - t.ok(fs.existsSync(path.join(home.APP_HOME, 'test', 'code'))) + t.ok(fs.existsSync(path.join(home.APP_HOME, 'test_code', 'code'))) - t.absent(home.isShared('test')) - t.absent(fs.existsSync(path.join(home.APP_HOME, 'test', '.git-daemon-export-ok'))) + t.absent(home.isShared('test_code')) + t.absent(fs.existsSync(path.join(home.APP_HOME, 'test_code', '.git-daemon-export-ok'))) - home.shareAppFolder('test') + home.shareAppFolder('test_code') - t.ok(home.isShared('test')) - t.ok(fs.existsSync(path.join(home.APP_HOME, 'test', '.git-daemon-export-ok'))) + t.ok(home.isShared('test_code')) + t.ok(fs.existsSync(path.join(home.APP_HOME, 'test_code', '.git-daemon-export-ok'))) - home.unshareAppFolder('test') + home.unshareAppFolder('test_code') - t.absent(home.isShared('test')) - t.absent(fs.existsSync(path.join(home.APP_HOME, 'test', '.git-daemon-export-ok'))) + t.absent(home.isShared('test_code')) + t.absent(fs.existsSync(path.join(home.APP_HOME, 'test_code', '.git-daemon-export-ok'))) - t.absent(home.isInitialized('test')) + t.absent(home.isInitialized('test_code')) t.ok(home.isInitialized('foo')) t.alike(new Set(home.list()), new Set(['foo', 'bar', 'zar'])) t.alike(new Set(home.list(true)), new Set(['foo', 'bar'])) - t.alike(path.resolve(home.getCodePath('test')), path.resolve(path.join(home.APP_HOME, 'test', 'code'))) + t.alike(path.resolve(home.getCodePath('test_code')), path.resolve(path.join(home.APP_HOME, 'test_code', 'code'))) t.teardown(() => { - fs.rmSync(path.join(home.APP_HOME, 'test', 'code'), { recursive: true }) + fs.rmSync(path.join(home.APP_HOME, 'test_code'), { recursive: true }) }) }) diff --git a/test_home.tar.gz b/test_home.tar.gz index 826e8ef..cdbf5e4 100644 Binary files a/test_home.tar.gz and b/test_home.tar.gz differ