Skip to content

Commit 0fd7664

Browse files
committed
rename msys tool api
1 parent 7c381f6 commit 0fd7664

5 files changed

Lines changed: 33 additions & 35 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
"terminal": {
116116
"profiles": [
117117
{
118-
"id": "eide.msys.bash",
119-
"title": "Eide Msys Bash"
118+
"id": "eide.unix.bash",
119+
"title": "Eide Bash"
120120
},
121121
{
122122
"id": "eide.system.shell",

src/Compress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class SevenZipper {
160160

161161
private _tar_path(): string {
162162
if (platform.osType() == 'win32') {
163-
return ResManager.instance().getMsysBinToolPath('tar');
163+
return ResManager.instance().getUnixTool('tar');
164164
} else {
165165
return 'tar';
166166
}

src/EIDEProject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,8 +3911,8 @@ class EIDEProject extends AbstractProject {
39113911
private async runInstallScript(prjRoot: File, scriptName: string, title?: string): Promise<boolean> {
39123912

39133913
const script = File.fromArray([prjRoot.path, AbstractProject.EIDE_DIR, scriptName]);
3914-
const bash = ResManager.GetInstance().getMsysBash();
3915-
if (!script.IsFile()) return true; // not found script, exit
3914+
if (!script.IsFile())
3915+
return true; // not found script, exit
39163916

39173917
try {
39183918

@@ -3942,7 +3942,7 @@ class EIDEProject extends AbstractProject {
39423942
resolve(exitInf.code == 0);
39433943
});
39443944

3945-
proc.Run(cmd, undefined, { cwd: prjRoot.path, shell: bash?.path });
3945+
proc.Run(cmd, undefined, { cwd: prjRoot.path, shell: ResManager.GetInstance().getUnixBash() });
39463946
});
39473947
});
39483948

src/ResManager.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,19 @@ export class ResManager extends events.EventEmitter {
431431
return <File>this.GetDir('builder');
432432
}
433433

434-
getMsysBash(): File | undefined {
434+
getUnixBash(): string {
435435
if (os.platform() == 'win32') {
436-
return File.fromArray([this.getLegacyBuilderDir().path, 'msys', 'bin', `bash${exeSuffix()}`]);
436+
return File.from(this.getLegacyBuilderDir().path, 'msys', 'bin', `bash${exeSuffix()}`).path;
437+
} else {
438+
const bash = '/bin/bash';
439+
const sh = '/bin/sh';
440+
return File.IsExist(bash) ? bash : sh;
437441
}
438442
}
439443

440-
getMsysBinToolPath(toolname: string): string {
444+
getUnixTool(toolname: string): string {
441445
if (os.platform() == 'win32') {
442-
return File.fromArray([this.getLegacyBuilderDir().path, 'msys', 'bin', `${toolname}${exeSuffix()}`]).path;
446+
return File.from(this.getLegacyBuilderDir().path, 'msys', 'bin', `${toolname}${exeSuffix()}`).path;
443447
} else {
444448
return `${toolname}${exeSuffix()}`;
445449
}
@@ -462,12 +466,6 @@ export class ResManager extends events.EventEmitter {
462466

463467
/* ----------------------------------- */
464468

465-
/**
466-
* @deprecated
467-
*/
468-
GetBinDir(): File {
469-
return <File>this.GetDir('bin');
470-
}
471469
getBinDir(): File {
472470
return <File>this.GetDir('bin');
473471
}

src/extension.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean>
527527

528528
const resManager = ResManager.GetInstance();
529529

530-
const binFolder = resManager.GetBinDir();
530+
const binFolder = resManager.getBinDir();
531531
const eideCfg = resManager.getAppConfig<any>();
532532
const minReqVersion = eideCfg['binary_min_version'];
533533

@@ -854,7 +854,7 @@ function onBinariesInstallDone() {
854854

855855
// get exe file list from folders
856856
for (const dir of [
857-
File.fromArray([resManager.GetBinDir().path, 'scripts']),
857+
File.fromArray([resManager.getBinDir().path, 'scripts']),
858858
File.fromArray([resManager.getLegacyBuilderDir().path, 'utils'])
859859
]) {
860860
dir.GetList(undefined, File.EXCLUDE_ALL_FILTER)
@@ -892,6 +892,9 @@ function cleanLegacyUnifyBuilder() {
892892
}
893893
}
894894

895+
async function patchBinaries() {
896+
}
897+
895898
//////////////////////////////////////////////////
896899
// environment sutup
897900
//////////////////////////////////////////////////
@@ -913,7 +916,7 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
913916
File.normalize(`${resManager.getBuiltInToolsDir().path}/utils`) // builtin util tools
914917
];
915918

916-
//
919+
// create ~/.eide/tools dir
917920
const eideToolsFolder = new File(File.normalize(`${platform.userhome()}/.eide/tools`));
918921
if (!eideToolsFolder.IsDir()) {
919922
try {
@@ -1220,6 +1223,9 @@ async function InitComponents(context: vscode.ExtensionContext): Promise<boolean
12201223
const done = await checkAndInstallBinaries();
12211224
if (!done) { return false; } /* exit if failed */
12221225

1226+
// binaries patchs
1227+
await patchBinaries();
1228+
12231229
// check and install .NET6 runtime
12241230
await checkAndInstallRuntime();
12251231

@@ -1257,10 +1263,10 @@ async function InitComponents(context: vscode.ExtensionContext): Promise<boolean
12571263
bar_flash.tooltip = `Upload binary file to device`;
12581264
}
12591265

1260-
// register msys bash profile for windows
1266+
// register bash profile for windows
12611267
if (os.platform() == 'win32') {
1262-
context.subscriptions.push(vscode.window.registerTerminalProfileProvider(EideTerminalProvider.MSYS_BASH_ID,
1263-
new EideTerminalProvider(EideTerminalProvider.MSYS_BASH_ID)));
1268+
context.subscriptions.push(vscode.window.registerTerminalProfileProvider(EideTerminalProvider.UNIX_BASH_ID,
1269+
new EideTerminalProvider(EideTerminalProvider.UNIX_BASH_ID)));
12641270
}
12651271

12661272
context.subscriptions.push(
@@ -1379,7 +1385,7 @@ class EideTaskProvider implements vscode.TaskProvider {
13791385

13801386
if (platform.osType() == 'win32') {
13811387
if (SettingManager.GetInstance().isEnableMsys()) {
1382-
bash_executable = `${process.env['EIDE_MSYS']}/bash.exe`;
1388+
bash_executable = ResManager.instance().getUnixBash();
13831389
} else {
13841390
bash_executable = `bash.exe`;
13851391
}
@@ -1524,7 +1530,7 @@ class EideTerminalLinkProvider implements vscode.TerminalLinkProvider<EideTermin
15241530

15251531
class EideTerminalProvider implements vscode.TerminalProfileProvider {
15261532

1527-
public static readonly MSYS_BASH_ID = 'eide.msys.bash';
1533+
public static readonly UNIX_BASH_ID = 'eide.unix.bash';
15281534
public static readonly SYSTEM_SHELL_ID = 'eide.system.shell';
15291535

15301536
private type: string;
@@ -1536,8 +1542,8 @@ class EideTerminalProvider implements vscode.TerminalProfileProvider {
15361542
provideTerminalProfile(token: vscode.CancellationToken): vscode.ProviderResult<vscode.TerminalProfile> {
15371543

15381544
switch (this.type) {
1539-
case EideTerminalProvider.MSYS_BASH_ID:
1540-
return this.provideMsysTerminal();
1545+
case EideTerminalProvider.UNIX_BASH_ID:
1546+
return this.provideBashTerminal();
15411547
case EideTerminalProvider.SYSTEM_SHELL_ID:
15421548
return this.provideSystemTerminal();
15431549
default:
@@ -1602,25 +1608,19 @@ class EideTerminalProvider implements vscode.TerminalProfileProvider {
16021608
});
16031609
}
16041610

1605-
private provideMsysTerminal(): vscode.ProviderResult<vscode.TerminalProfile> {
1611+
private provideBashTerminal(): vscode.ProviderResult<vscode.TerminalProfile> {
16061612

16071613
// welcome msg
16081614
const welcome = [
16091615
`--------------------------------------------`,
1610-
` \x1b[32;22m welcome to msys bash \x1b[0m`,
1616+
` \x1b[32;22m welcome to bash \x1b[0m`,
16111617
`--------------------------------------------`,
16121618
``
16131619
];
16141620

1615-
// check bash folder
1616-
if (!process.env['EIDE_MSYS'] ||
1617-
!File.IsDir(process.env['EIDE_MSYS'])) {
1618-
return undefined;
1619-
}
1620-
16211621
return new vscode.TerminalProfile({
16221622
name: 'msys bash',
1623-
shellPath: `${process.env['EIDE_MSYS']}/bash.exe`,
1623+
shellPath: ResManager.instance().getUnixBash(),
16241624
cwd: this.cwd(true),
16251625
env: process.env,
16261626
strictEnv: true,

0 commit comments

Comments
 (0)