mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-15 15:26:32 +00:00
ATL-1145: Suppress error if Git is not on $PATH
.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
d45dd6beef
commit
a8df2444a9
@ -34,6 +34,8 @@ import { NotificationServiceServerImpl } from './notification-service-server';
|
||||
import { NotificationServiceServer, NotificationServiceClient, NotificationServicePath } from '../common/protocol';
|
||||
import { BackendApplication } from './theia/core/backend-application';
|
||||
import { BoardDiscovery } from './board-discovery';
|
||||
import { DefaultGitInit } from './theia/git/git-init';
|
||||
import { GitInit } from '@theia/git/lib/node/init/git-init';
|
||||
|
||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
bind(BackendApplication).toSelf().inSingletonScope();
|
||||
@ -164,4 +166,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
return parentLogger.child('monitor-service');
|
||||
}).inSingletonScope().whenTargetNamed('monitor-service');
|
||||
|
||||
bind(DefaultGitInit).toSelf();
|
||||
rebind(GitInit).toService(DefaultGitInit);
|
||||
|
||||
});
|
||||
|
44
arduino-ide-extension/src/node/theia/git/git-init.ts
Normal file
44
arduino-ide-extension/src/node/theia/git/git-init.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { injectable } from 'inversify';
|
||||
import findGit from 'find-git-exec';
|
||||
import { dirname } from 'path';
|
||||
import { pathExists } from 'fs-extra';
|
||||
import { GitInit } from '@theia/git/lib/node/init/git-init';
|
||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||
|
||||
@injectable()
|
||||
export class DefaultGitInit implements GitInit {
|
||||
|
||||
protected readonly toDispose = new DisposableCollection();
|
||||
|
||||
async init(): Promise<void> {
|
||||
const { env } = process;
|
||||
try {
|
||||
const { execPath, path, version } = await findGit();
|
||||
if (!!execPath && !!path && !!version) {
|
||||
const dir = dirname(dirname(path));
|
||||
const [execPathOk, pathOk, dirOk] = await Promise.all([pathExists(execPath), pathExists(path), pathExists(dir)]);
|
||||
if (execPathOk && pathOk && dirOk) {
|
||||
if (typeof env.LOCAL_GIT_DIRECTORY !== 'undefined' && env.LOCAL_GIT_DIRECTORY !== dir) {
|
||||
console.error(`Misconfigured env.LOCAL_GIT_DIRECTORY: ${env.LOCAL_GIT_DIRECTORY}. dir was: ${dir}`);
|
||||
return;
|
||||
}
|
||||
if (typeof env.GIT_EXEC_PATH !== 'undefined' && env.GIT_EXEC_PATH !== execPath) {
|
||||
console.error(`Misconfigured env.GIT_EXEC_PATH: ${env.GIT_EXEC_PATH}. execPath was: ${execPath}`);
|
||||
return;
|
||||
}
|
||||
process.env.LOCAL_GIT_DIRECTORY = dir;
|
||||
process.env.GIT_EXEC_PATH = execPath;
|
||||
console.info(`Using Git [${version}] from the PATH. (${path})`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.toDispose.dispose();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user