Files
azuredatastudio/src/vs/base/test/node/utils.ts
Anthony Dresser 0b7e7ddbf9 Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
2019-07-15 22:35:46 -07:00

29 lines
1006 B
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { generateUuid } from 'vs/base/common/uuid';
import { join } from 'vs/base/common/path';
import { tmpdir } from 'os';
import { mkdirp, rimraf, RimRafMode } from 'vs/base/node/pfs';
export interface ITestFileResult {
testFile: string;
cleanUp: () => Promise<void>;
}
export function testFile(folder: string, file: string): Promise<ITestFileResult> {
const id = generateUuid();
const parentDir = join(tmpdir(), 'vsctests', id);
const newDir = join(parentDir, folder, id);
const testFile = join(newDir, file);
return mkdirp(newDir, 493).then(() => {
return {
testFile,
cleanUp: () => rimraf(parentDir, RimRafMode.MOVE)
};
});
}