feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
21
api.hyungi.net/node_modules/git-node-fs/LICENSE
generated
vendored
Normal file
21
api.hyungi.net/node_modules/git-node-fs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Tim Caswell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
23
api.hyungi.net/node_modules/git-node-fs/README.md
generated
vendored
Normal file
23
api.hyungi.net/node_modules/git-node-fs/README.md
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
git-node-fs
|
||||
===========
|
||||
|
||||
A node adapter for the fs-db mixin for [js-git].
|
||||
This enables access to Git repositories on the filesystem using Node.js.
|
||||
|
||||
```js
|
||||
var repo = {};
|
||||
repo.rootPath = path.join(__dirname, ".git");
|
||||
var fs = require("git-node-fs");
|
||||
require("js-git/mixins/fs-db")(repo, fs);
|
||||
```
|
||||
|
||||
Or use the provided mixin directly.
|
||||
|
||||
```js
|
||||
var repo = {};
|
||||
var path = path.join("some/bare/repo.git");
|
||||
require('git-node-fs/mixins/fs-db')(repo, path);
|
||||
```
|
||||
|
||||
[js-git]: https://github.com/creationix/js-git
|
||||
|
||||
146
api.hyungi.net/node_modules/git-node-fs/lib/node-fs.js
generated
vendored
Normal file
146
api.hyungi.net/node_modules/git-node-fs/lib/node-fs.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var nodeFs = require("fs");
|
||||
var nodePath = require("path");
|
||||
|
||||
// Implements the fs interface required by js-git/fs-db
|
||||
var fs = module.exports = {};
|
||||
|
||||
fs.readFile = readFile;
|
||||
fs.readChunk = readChunk;
|
||||
fs.writeFile = writeFile;
|
||||
fs.readDir = readDir;
|
||||
fs.rename = rename;
|
||||
|
||||
// Reads all bytes for given path.
|
||||
// => binary
|
||||
// => undefined if file does not exist
|
||||
function readFile(path, callback) {
|
||||
nodeFs.readFile(path, function (err, binary) {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") return callback();
|
||||
return callback(err);
|
||||
}
|
||||
return callback(null, binary);
|
||||
});
|
||||
}
|
||||
|
||||
// Reads bytes from inclusive [start, end) exclusive for given path.
|
||||
// => binary
|
||||
// => undefined if file does not exist
|
||||
function readChunk(path, start, end, callback) {
|
||||
if (end < 0) {
|
||||
return readLastChunk(path, start, end, callback);
|
||||
}
|
||||
var stream = nodeFs.createReadStream(path, {
|
||||
start: start,
|
||||
end: end - 1
|
||||
});
|
||||
var chunks = [];
|
||||
stream.on("readable", function () {
|
||||
var chunk = stream.read();
|
||||
if (chunk === null) return callback(null, Buffer.concat(chunks));
|
||||
return chunks.push(chunk);
|
||||
});
|
||||
stream.on("error", function (err) {
|
||||
if (err.code === "ENOENT") return callback();
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
// Node.js readable streams do not support reading from a position to the end
|
||||
// of the file, but we can roll our own using the lower-level fs.open and
|
||||
// fs.read on a file descriptor, which allows read to seek.
|
||||
function readLastChunk(path, start, end, callback) {
|
||||
nodeFs.open(path, "r", function (err, fd) {
|
||||
if (err) {
|
||||
if (err.code === "EACCES") return callback();
|
||||
return callback(err);
|
||||
}
|
||||
var buffer = new Buffer(4096);
|
||||
var length = 0;
|
||||
read();
|
||||
// Only the first read needs to seek.
|
||||
// All subsequent reads will continue from the end of the previous.
|
||||
start = null;
|
||||
|
||||
function read() {
|
||||
if (buffer.length - length === 0) {
|
||||
grow();
|
||||
}
|
||||
nodeFs.read(fd, buffer, length, buffer.length - length, start, onread);
|
||||
}
|
||||
|
||||
function onread(err, bytesRead) {
|
||||
if (err) return callback(err);
|
||||
length += bytesRead;
|
||||
if (bytesRead === 0) {
|
||||
return callback(null, buffer.slice(0, buffer.length + end));
|
||||
}
|
||||
read();
|
||||
}
|
||||
|
||||
function grow() {
|
||||
var newBuffer = new Buffer(buffer.length * 2);
|
||||
buffer.copy(newBuffer);
|
||||
buffer = newBuffer;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Writes all bytes over file at given path.
|
||||
// Creates all necessary parent directories.
|
||||
// => undefined
|
||||
function writeFile(path, binary, callback) {
|
||||
mkdirp(nodePath.dirname(path), function (err) {
|
||||
if (err) return callback(err);
|
||||
nodeFs.writeFile(path, binary, callback);
|
||||
});
|
||||
}
|
||||
|
||||
// Renames the given file.
|
||||
// Creates all necessary parent directories.
|
||||
// => undefined
|
||||
function rename(oldPath, newPath, callback) {
|
||||
var oldBase = nodePath.dirname(oldPath);
|
||||
var newBase = nodePath.dirname(newPath);
|
||||
if (oldBase === newBase) {
|
||||
return nodeFs.rename(oldPath, newPath, callback);
|
||||
}
|
||||
mkdirp(nodePath.dirname(path), function (err) {
|
||||
if (err) return callback(err);
|
||||
nodeFs.rename(oldPath, newPath, callback);
|
||||
});
|
||||
}
|
||||
|
||||
// Reads all entry names for a given path.
|
||||
// All names are relative to the directory itself, not fully qualified paths.
|
||||
// => array<name>
|
||||
// => undefined if directory does not exist
|
||||
function readDir(path, callback) {
|
||||
nodeFs.readdir(path, function (err, names) {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") return callback();
|
||||
return callback(err);
|
||||
}
|
||||
return callback(null, names);
|
||||
});
|
||||
}
|
||||
|
||||
function mkdirp(path, callback) {
|
||||
nodeFs.mkdir(path, function (err) {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") {
|
||||
return mkdirp(nodePath.dirname(path), function (err) {
|
||||
if (err) return callback(err);
|
||||
nodeFs.mkdir(path, function (err) {
|
||||
if (err && err.code !== "EEXIST") return callback(err);
|
||||
return callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
if (err.code === "EEXIST") return callback();
|
||||
return callback(err);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
7
api.hyungi.net/node_modules/git-node-fs/mixins/fs-db.js
generated
vendored
Normal file
7
api.hyungi.net/node_modules/git-node-fs/mixins/fs-db.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
var fsDb = require('js-git/mixins/fs-db');
|
||||
var nodeFs = require('../lib/node-fs');
|
||||
|
||||
module.exports = function (repo, rootPath) {
|
||||
repo.rootPath = rootPath;
|
||||
fsDb(repo, nodeFs);
|
||||
};
|
||||
22
api.hyungi.net/node_modules/git-node-fs/package.json
generated
vendored
Normal file
22
api.hyungi.net/node_modules/git-node-fs/package.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "git-node-fs",
|
||||
"description": "A node adapter for the fs-db mixin for js-git",
|
||||
"keywords": [
|
||||
"git",
|
||||
"js-git"
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"main": "lib/node-fs.js",
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/creationix/git-node-fs.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/creationix/git-node-fs/issues"
|
||||
},
|
||||
"homepage": "https://github.com/creationix/git-node-fs"
|
||||
}
|
||||
48
api.hyungi.net/node_modules/git-node-fs/test.js
generated
vendored
Normal file
48
api.hyungi.net/node_modules/git-node-fs/test.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
var assert = require("assert");
|
||||
var path = require("path");
|
||||
var fs = require("./lib/node-fs");
|
||||
var nodeFs = require("fs");
|
||||
|
||||
var directoryPath = path.join(__dirname, "test", "fixtures");
|
||||
var temporaryPath = path.join(__dirname, "test", "temporary.txt");
|
||||
var numbersPath = path.join(directoryPath, "numbers.txt");
|
||||
var nonPath = path.join(directoryPath, "nope.txt");
|
||||
|
||||
fs.readFile(numbersPath, function (err, numbers) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(numbers.toString("utf-8"), "0123456789\n");
|
||||
});
|
||||
|
||||
fs.readFile(nonPath, function (err, numbers) {
|
||||
assert.strictEqual(err, undefined);
|
||||
assert.strictEqual(numbers, undefined);
|
||||
});
|
||||
|
||||
fs.readChunk(numbersPath, 2, 4, function (err, numbers) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(numbers.toString("utf-8"), "23");
|
||||
});
|
||||
|
||||
fs.readChunk(nonPath, 2, 4, function (err, numbers) {
|
||||
assert.strictEqual(err, undefined);
|
||||
assert.strictEqual(numbers, undefined);
|
||||
});
|
||||
|
||||
fs.readDir(directoryPath, function (err, names) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(1, names.length);
|
||||
assert.strictEqual("numbers.txt", names[0]);
|
||||
});
|
||||
|
||||
fs.writeFile(temporaryPath, new Buffer("Hello, World!\n"), function (err) {
|
||||
assert.strictEqual(err, null);
|
||||
fs.readFile(temporaryPath, function (err, content) {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual("Hello, World!\n", content.toString());
|
||||
nodeFs.unlink(temporaryPath, function (err) {
|
||||
assert.strictEqual(err, null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
1
api.hyungi.net/node_modules/git-node-fs/test/fixtures/numbers.txt
generated
vendored
Normal file
1
api.hyungi.net/node_modules/git-node-fs/test/fixtures/numbers.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0123456789
|
||||
Reference in New Issue
Block a user