Skip to content

Commit a11c9b2

Browse files
committed
add zip tests
1 parent 65aeaf7 commit a11c9b2

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/vs/base/node/zip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): Pr
6969
});
7070
}
7171

72-
export function extract(zipPath: string, targetPath: string, options: IExtractOptions): Promise {
72+
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}): Promise {
7373
const sourcePathRegex = new RegExp(options.sourcePath ? `^${ options.sourcePath }` : '');
7474

7575
let promise = nfcall<ZipFile>(openZip, zipPath);
1013 Bytes
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
'use strict';
7+
8+
import * as assert from 'assert';
9+
import * as path from 'path';
10+
import * as os from 'os';
11+
import URI from 'vs/base/common/uri';
12+
import { extract } from 'vs/base/node/zip';
13+
import { generateUuid } from 'vs/base/common/uuid';
14+
import { rimraf, exists } from 'vs/base/node/pfs';
15+
16+
const fixtures = URI.parse(require.toUrl('./fixtures')).fsPath;
17+
18+
suite('Zip', () => {
19+
20+
test('extract should handle directories', () => {
21+
const fixture = path.join(fixtures, 'extract.zip');
22+
const target = path.join(os.tmpdir(), generateUuid());
23+
24+
return extract(fixture, target)
25+
.then(() => exists(path.join(target, 'extension', '1', '2', 'README.md')))
26+
.then(exists => assert(exists))
27+
.then(() => rimraf(target));
28+
});
29+
});

0 commit comments

Comments
 (0)