Пример #1
0
module.exports = function(dir) {
	let repType = repTypeCache[dir];

	if (!repType) {
		repType = fs.statAsync(path.join(dir, ".git"))

		.then(stat => {
			if (stat.isDirectory()) {
				return "git";
			} else {
				throw new Error("不是git项目");
			}
		})

		.catch(() => {
			return fs.statAsync(path.join(dir, ".hg"))

			.then(stat => {
				if (stat.isDirectory()) {
					return "hg";
				} else {
					throw new Error("不是hg项目");
				}
			});

		});
		repTypeCache[dir] = repType;
	}
	return repType;
};
Пример #2
0
		.catch(() => {
			return fs.statAsync(path.join(dir, ".hg"))

			.then(stat => {
				if (stat.isDirectory()) {
					return "hg";
				} else {
					throw new Error("不是hg项目");
				}
			});

		});