Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 84b4b8a

Browse files
committed
Merge pull request #286 from telerik/unzip
Use info-zip based unzip on windows, and OS supplied one on linux
2 parents c671399 + 373b198 commit 84b4b8a

File tree

10 files changed

+26
-20
lines changed

10 files changed

+26
-20
lines changed

commands/post-install.ts

-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class PostInstallCommand implements ICommand {
1313

1414
constructor(private $fs: IFileSystem,
1515
private $staticConfig: Config.IStaticConfig,
16-
private $childProcess: IChildProcess,
1716
private $commandsService: ICommandsService,
1817
private $htmlHelpService: IHtmlHelpService,
1918
private $sysInfo: ISysInfo,
@@ -43,8 +42,6 @@ export class PostInstallCommand implements ICommand {
4342
this.printAppBuilderWarnings(sysInfo);
4443
}
4544

46-
this.checkSevenZip().wait();
47-
4845
this.$commandsService.tryExecuteCommand("autocomplete", []).wait();
4946
}).future<void>()();
5047
}
@@ -139,10 +136,5 @@ export class PostInstallCommand implements ICommand {
139136
+ "or http://docs.oracle.com/javase/7/docs/webnotes/install/ (for JDK 7)." + os.EOL);
140137
}
141138
}
142-
143-
private checkSevenZip(): IFuture<void> {
144-
var sevenZipErrorMessage = util.format(PostInstallCommand.SEVEN_ZIP_ERROR_MESSAGE, this.$staticConfig.SYS_REQUIREMENTS_LINK);
145-
return this.$childProcess.tryExecuteApplication(this.$staticConfig.sevenZipFilePath, ["-h"], "exit", sevenZipErrorMessage);
146-
}
147139
}
148140
$injector.registerCommand("dev-post-install", PostInstallCommand);

definitions/config.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ declare module Config {
1111
version: string;
1212
helpTextPath: string;
1313
adbFilePath: string;
14-
sevenZipFilePath: string;
1514
disableAnalytics?: boolean;
1615
disableHooks?: boolean;
1716
enableDeviceRunCommandOnWindows?: boolean;

file-system.ts

+26-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Future = require("fibers/future");
66
import path = require("path");
77
import util = require("util");
88
import rimraf = require("rimraf");
9+
import minimatch = require("minimatch");
910
import hostInfo = require("./host-info");
1011

1112
export class FileSystem implements IFileSystem {
@@ -55,20 +56,38 @@ export class FileSystem implements IFileSystem {
5556
return (() => {
5657
var shouldOverwriteFiles = !(options && options.overwriteExisitingFiles === false);
5758
var isCaseSensitive = !(options && options.caseSensitive === false);
58-
59-
//the wild card symbol at the end is required in order for the -ssc- switch of 7zip to behave properly
60-
zipFile = isCaseSensitive ? zipFile : zipFile + '*';
6159

6260
this.createDirectory(destinationDir).wait();
63-
var args = <string[]>(_.flatten(['x', shouldOverwriteFiles ? "-y" : "-aos", '-o' + destinationDir, isCaseSensitive ? '-ssc' : '-ssc-', zipFile, fileFilters || []]));
6461

65-
var $childProcess = this.$injector.resolve("childProcess");
66-
var $staticConfig = this.$injector.resolve("staticConfig");
62+
var proc: string;
63+
if (hostInfo.isWindows()) {
64+
proc = path.join(__dirname, "resources/platform-tools/unzip/win32/unzip");
65+
} else if (hostInfo.isDarwin()) {
66+
proc = "unzip"; // darwin unzip is info-zip
67+
} else if (hostInfo.isLinux()) {
68+
proc = "unzip"; // linux unzip is info-zip
69+
}
70+
71+
if (!isCaseSensitive) {
72+
zipFile = this.findFileCaseInsensitive(zipFile);
73+
}
74+
75+
var args = <string[]>(_.flatten(['-b', shouldOverwriteFiles ? "-o" : "-n", isCaseSensitive ? [] : '-C', zipFile, fileFilters || [], '-d', destinationDir]));
6776

68-
$childProcess.spawnFromEvent($staticConfig.sevenZipFilePath, args, "close", { stdio: "ignore", detached: true }).wait();
77+
var $childProcess = this.$injector.resolve("childProcess");
78+
$childProcess.spawnFromEvent(proc, args, "close", { stdio: "ignore", detached: true }).wait();
6979
}).future<void>()();
7080
}
7181

82+
private findFileCaseInsensitive(file: string): string {
83+
var dir = path.dirname(file);
84+
var basename = path.basename(file);
85+
var entries = this.readDirectory(dir).wait();
86+
var match = minimatch.match(entries, basename, {nocase:true, nonegate: true, nonull: true})[0];
87+
var result = path.join(dir, match);
88+
return result;
89+
}
90+
7291
public exists(path: string): IFuture<boolean> {
7392
var future = new Future<boolean>();
7493
fs.exists(path, (exists: boolean) => future.return(exists));
-1.38 MB
Binary file not shown.
-1.37 MB
Binary file not shown.
-220 KB
Binary file not shown.
-590 KB
Binary file not shown.
-126 KB
Binary file not shown.
258 KB
Binary file not shown.

static-config-base.ts

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ export class StaticConfigBase implements Config.IStaticConfig {
1717
return null;
1818
}
1919

20-
public get sevenZipFilePath(): string {
21-
return path.join(__dirname, util.format("resources/platform-tools/unzip/%s/7za", process.platform));
22-
}
23-
2420
public get adbFilePath(): string {
2521
return path.join(__dirname, util.format("resources/platform-tools/android/%s/adb", process.platform));
2622
}

0 commit comments

Comments
 (0)