Skip to content

Commit

Permalink
fix: fix git repository detection
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 15, 2018
1 parent 7a22b48 commit 3ba4350
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/setup-repository.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"use strict";

const isObject = require("es5-ext/object/is-object")
, { resolve } = require("path")
, log = require("log4").get("npm-cross-link")
, isDirectory = require("fs2/is-directory")
, rm = require("fs2/rm")
, NpmCrossLinkError = require("./npm-cross-link-error")
, runProgram = require("./run-program");

module.exports = async (path, repoUrl, options = {}) => {
if (!isObject(options)) options = {};
const report = new Set();
if (await isDirectory(path)) {
if (await isDirectory(resolve(path, ".git"))) {
const tryPull = options.pull, tryPush = options.push;

if (!tryPull && !tryPush) return report;
Expand Down Expand Up @@ -57,6 +59,7 @@ module.exports = async (path, repoUrl, options = {}) => {
}
return report;
}
await rm(path, { loose: true, recursive: true, force: true });
log.info("clone repository %s from %s", path, repoUrl);
await runProgram("git", ["clone", repoUrl, path], { logger: log.levelRoot.get("git:clone") });
report.add("clone");
Expand Down

0 comments on commit 3ba4350

Please sign in to comment.