Fix git integration bug
This commit is contained in:
parent
c1dc899bc1
commit
9685dfb55a
@ -1,15 +1,31 @@
|
|||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { dirname as pathDirname, basename as pathBasename } from "path";
|
import {
|
||||||
|
dirname as pathDirname,
|
||||||
|
basename as pathBasename,
|
||||||
|
join as pathJoin,
|
||||||
|
sep as pathSep
|
||||||
|
} from "path";
|
||||||
import { Deferred } from "evt/tools/Deferred";
|
import { Deferred } from "evt/tools/Deferred";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
export function getIsKnownByGit(params: { filePath: string }): Promise<boolean> {
|
export function getIsKnownByGit(params: { filePath: string }): Promise<boolean> {
|
||||||
const { filePath } = params;
|
const { filePath } = params;
|
||||||
|
|
||||||
const dIsKnownByGit = new Deferred<boolean>();
|
const dIsKnownByGit = new Deferred<boolean>();
|
||||||
|
|
||||||
|
let relativePath = pathBasename(filePath);
|
||||||
|
|
||||||
|
let dirPath = pathDirname(filePath);
|
||||||
|
|
||||||
|
while (!fs.existsSync(dirPath)) {
|
||||||
|
relativePath = pathJoin(pathBasename(dirPath), relativePath);
|
||||||
|
|
||||||
|
dirPath = pathDirname(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
child_process.exec(
|
child_process.exec(
|
||||||
`git ls-files --error-unmatch ${pathBasename(filePath)}`,
|
`git ls-files --error-unmatch '${relativePath.split(pathSep).join("/")}'`,
|
||||||
{ cwd: pathDirname(filePath) },
|
{ cwd: dirPath },
|
||||||
error => {
|
error => {
|
||||||
if (error === null) {
|
if (error === null) {
|
||||||
dIsKnownByGit.resolve(true);
|
dIsKnownByGit.resolve(true);
|
||||||
|
@ -108,7 +108,7 @@ async function runPackageManagerInstall(params: {
|
|||||||
child.stdout.on("data", data => process.stdout.write(data));
|
child.stdout.on("data", data => process.stdout.write(data));
|
||||||
|
|
||||||
child.stderr.on("data", data => {
|
child.stderr.on("data", data => {
|
||||||
if (data.toString("utf8").includes("has unmet peer dependency")) {
|
if (data.toString("utf8").includes("peer dependency")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { dirname as pathDirname, basename as pathBasename } from "path";
|
import {
|
||||||
|
dirname as pathDirname,
|
||||||
|
basename as pathBasename,
|
||||||
|
join as pathJoin,
|
||||||
|
sep as pathSep
|
||||||
|
} from "path";
|
||||||
import { Deferred } from "evt/tools/Deferred";
|
import { Deferred } from "evt/tools/Deferred";
|
||||||
|
import { existsAsync } from "./fs.existsAsync";
|
||||||
|
|
||||||
export async function untrackFromGit(params: { filePath: string }): Promise<void> {
|
export async function untrackFromGit(params: { filePath: string }): Promise<void> {
|
||||||
const { filePath } = params;
|
const { filePath } = params;
|
||||||
|
|
||||||
const dDone = new Deferred<void>();
|
const dDone = new Deferred<void>();
|
||||||
|
|
||||||
|
let relativePath = pathBasename(filePath);
|
||||||
|
|
||||||
|
let dirPath = pathDirname(filePath);
|
||||||
|
|
||||||
|
while (!(await existsAsync(dirPath))) {
|
||||||
|
relativePath = pathJoin(pathBasename(dirPath), relativePath);
|
||||||
|
|
||||||
|
dirPath = pathDirname(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
child_process.exec(
|
child_process.exec(
|
||||||
`git rm --cached ${pathBasename(filePath)}`,
|
`git rm --cached '${relativePath.split(pathSep).join("/")}'`,
|
||||||
{ cwd: pathDirname(filePath) },
|
{ cwd: dirPath },
|
||||||
error => {
|
error => {
|
||||||
if (error !== null) {
|
if (error !== null) {
|
||||||
dDone.reject(error);
|
dDone.reject(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user