提交 a11c9b24 编写于 作者: J Joao Moreno

add zip tests

上级 65aeaf7f
......@@ -69,7 +69,7 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): Pr
});
}
export function extract(zipPath: string, targetPath: string, options: IExtractOptions): Promise {
export function extract(zipPath: string, targetPath: string, options: IExtractOptions = {}): Promise {
const sourcePathRegex = new RegExp(options.sourcePath ? `^${ options.sourcePath }` : '');
let promise = nfcall<ZipFile>(openZip, zipPath);
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import * as path from 'path';
import * as os from 'os';
import URI from 'vs/base/common/uri';
import { extract } from 'vs/base/node/zip';
import { generateUuid } from 'vs/base/common/uuid';
import { rimraf, exists } from 'vs/base/node/pfs';
const fixtures = URI.parse(require.toUrl('./fixtures')).fsPath;
suite('Zip', () => {
test('extract should handle directories', () => {
const fixture = path.join(fixtures, 'extract.zip');
const target = path.join(os.tmpdir(), generateUuid());
return extract(fixture, target)
.then(() => exists(path.join(target, 'extension', '1', '2', 'README.md')))
.then(exists => assert(exists))
.then(() => rimraf(target));
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册